Playground SIGABRT

Using a playground to display a view controller that has a uicollectionview. When I go to dequeue the cell, I get a SICABRT. Switched to simpler cell type and the issue still happens.


var collectionView:UICollectionView!


let flowLayout = UICollectionViewFlowLayout()

flowLayout.scrollDirection = UICollectionViewScrollDirection.Horizontal


self.collectionView = UICollectionView(frame: CGRect(x: 0.0, y: 0.0, width: self.frame.size.width, height: kDayViewHeight), collectionViewLayout: flowLayout)

self.collectionView.translatesAutoresizingMaskIntoConstraints = false

self.collectionView!.delegate = self

self.collectionView!.dataSource = self

self.collectionView.contentOffset = CGPoint(x: 0.0, y: 0.0)

self.collectionView.allowsSelection = true

self.collectionView.allowsMultipleSelection = false

self.collectionView.backgroundColor = UIColor.whiteColor()

self.collectionView.showsVerticalScrollIndicator = false

self.collectionView.showsHorizontalScrollIndicator = false

self.collectionView.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: "cell")

self.addSubview(self.collectionView)


func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell

{

let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as UICollectionViewCell

return cell

}


Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

Are you sure you entered "cell" as an identifier in the storyboard?


It would be case sensitive.

I think this may have to do with how I am building the screen.


UIViewController

UIView

UICollectionView


I think the issue maybe that the stack may be to complex for Storyboards. I imported the code to a swift file and it works. I think this would work if the UICollectionView were part of the VC.

Playground SIGABRT
 
 
Q