Binding to NSCollectionViewItem crashes Xcode

淺唱寂寞╮ 提交于 2019-12-06 01:32:39

I found that splitting the collection view item view into its own XIB and then rewiring the connections so that the collection view item prototype loads the new XIB will allow for you to create the bindings in interface builder without it crashing. I followed these steps...

  1. Delete the collection view item view from the default xib.
  2. Create a new view and XIB inheriting from NSCollectionViewItem.
  3. Create your collection view item in the new view.
  4. Bind the fields to the files owner of the new view.
  5. Back in the collection view xib, update the properties of collection view item to load the bin name of the new xib.

I'm not sure that it's quicker than doing it programmatically, but it does allow you to manage the bindings without writing code. I've got a few apps working this way now.

I've found a temporary work around:

Select the "Collection View Item" and under the "Attributes Inspector" → "View Controller" settings, set "Nib Name" to "MainMenu".

Once you've done this, it won't crash, and you can set the bindings. Be sure to clear the "Nib Name" setting when building your app.

Yup, I can confirm this bug too, even on Interface Builder 3.

The only workaround is to do the binding programmatically:

[textField bind:@"value" toObject:collectionViewItem withKeyPath:@"representedObject.foo" options:nil];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!