Reputation:
Just by adding an NSCollectionView to Storyboard, the code won't compile with the error: Unknown segue relationship: Prototype.
Is this a known bug of Swift/XCode6-beta4 or am I missing something?
Upvotes: 12
Views: 2739
Reputation: 4702
In case you are using the OSX 10.11 SDK, the following info from Apple's release notes for it instructs not populating the itemPrototype
property at all anymore (that of course assumes your minimum deployment target is 10.11):
To use NSCollectionView’s new API model, you specify a layout by setting an NSCollectionView’s “collectionViewLayout” property, and either provide a “dataSource” or bind your CollectionView’s “content” to an NSArray or NSArrayController (see “Binding Content to an NSCollectionView”, below). You must also disconnect and discard the NSCollectionView’s “itemPrototype”, which is a vestige of the 10.10-and-earlier API model.
Upvotes: 3
Reputation: 21381
There's actually no need to create an extra XIB file when you are already using storyboards.
Remove the connection between the NSCollectionView
and the NSCollectionViewItem
Give the view item an identifier
Set the item prototype programmatically in your surrounding NSViewController
:
@IBOutlet weak var collectionView: NSCollectionView!
override func viewDidLoad() {
self.collectionView.itemPrototype = self.storyboard?.instantiateControllerWithIdentifier("collectionViewItem")
as NSCollectionViewItem
}
This keeps all UI views in one place and thus provides a nicer workaround than having an alien XIB file hanging around.
Upvotes: 5
Reputation: 1749
Update for Xcode 7 beta 6 (see release notes):
Interface Builder supports the new NSCollectionView API in 10.11, using dataSource and layouts like on iOS. (18997303)
Has anyone tried to work with it before? Should I just add an empty collection view to my story board, then create a nib file just for the collectionviewitem and finally link it via code?
Update for Xcode 7.1 beta 3
I've downloaded and tested the new beta today and the problem is still there. However they have strangely removed the workaround notes from the release notes as if they had fixed it...
Upvotes: 6
Reputation: 4785
This is a known bug, and is mentioned (with a workaround) in the release notes of Xcode 6 beta-5:
A storyboard may fail to compile after adding an NSCollectionView to it. (17009377)!
Workaround: Pick a xib that includes the NSCollectionView and load it into a Storyboard based View.!
Upvotes: 7