How to fix this "Prototype Segue" associated with my NSCollectionView (Xcode 7.0 beta)

So, I always wanted to code an OSX program with Swift, which needs a collection view. As for OSX, it does not use UICollectionView, but NSCollectionView (by the way, if you know any tutorial for use with Swift, it will be very useful!).

The thing is, I put the “Collection View” in my storyboard, make it my initial controller, and as the view was created, it also created the NSCollectionViewItem on the storyboard. In Xcode 6, the prototype element was absolutely not associated with any other storyboard element, but now in Xcode 7 it is created using the "Prototype Segue".

Problem: when I compile, I have this error:

Unknown segue relationship : Prototype

Does anyone have an idea how to fix it?

Thanks in advance, and sorry for my English -

+4
source share
2 answers

It seems you need to specify the connection manually.

  • Add the "CollectionViewItem" storyboard identifier to the collection view item.

screenshot

  1. Add the following code to view the DidLoad method in the Collection View controller (Swift example):

    self.collectionView.itemPrototype = self.storyboard!.instantiateControllerWithIdentifier("collectionViewItem") as! NSCollectionViewItem
    
+5
source

As in Xcode 7.2, nd OSX 10.11, the problem still exists, the only way to do this is by creating a nib-based collection view cell and calling the - (void) registerNib: (nullable NSNib *) nib forItemWithIdentifier :( NSString *) method in the view collection.

+2
source

All Articles