Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix this 'Prototype Segue' related with my NSCollectionView (Xcode 7.0 beta)

So I've always wanted to code a program for OSX with Swift that needs a Collection View. As it is for OSX, it doesn't use a UICollectionView but a NSCollectionView (by the way, if you know any tutorial to use these with Swift it'll be much appreciated !).

The thing is : I put a 'Collection View' in my storyboard, make it my initial controller, and as the view was created it also created a NSCollectionViewItem on the storyboard. In Xcode 6 the prototype item was absolutely not related to any other element of the storyboard, but now in Xcode 7 it is created with a 'Prototype Segue'.

Problem : When I compile, I've got this error :

Unknown segue relationship : Prototype

Anyone has an idea on how to fix it ?

Thanks in advance, and sorry for my english --'

like image 598
Marie Arkan Avatar asked Mar 16 '23 18:03

Marie Arkan


2 Answers

It seems you have to specify connection manually.

  1. Add "collectionViewItem" Storyboard ID to your collection view item.

screenshot

  1. Add the following code to viewDidLoad method of your Collection View's controller (Swift example):

    self.collectionView.itemPrototype = self.storyboard!.instantiateControllerWithIdentifier("collectionViewItem") as! NSCollectionViewItem
    
like image 176
EugZol Avatar answered Apr 29 '23 05:04

EugZol


As of XCode 7.2, nd OSX 10.11 the issue is still there, the only way around this is by creating a nib based collection view cell and calling the method - (void)registerNib:(nullable NSNib *)nib forItemWithIdentifier:(NSString *)identifier on the collection view.

like image 32
dubemike Avatar answered Apr 29 '23 05:04

dubemike