I am trying to use AsyncDisplayKit to load images into my app. I am creating my collection view as an ASCollectionView, like so, in the viewDidLoad:
let layout = UICollectionViewFlowLayout()
layout.itemSize = CGSize(width: 90, height: 90)
let collection = ASCollectionView(frame: view.frame, collectionViewLayout: layout)
collection.asyncDataSource = self
collection.asyncDelegate = self
collection.registerClass(cell1.self, forCellWithReuseIdentifier: "cell1")
self.view.layer.addSublayer(collection.layer)
Here is my nodeForItemAtIndexPath:
func collectionView(collectionView: ASCollectionView, nodeForItemAtIndexPath indexPath:
NSIndexPath) -> ASCellNode {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell1",
forIndexPath: indexPath) as! cell1
return cell
}
nodeForItemAtindexPath is the AsyncDisplayKit version of cellForItemAtIndexPath. It must be used with the ASCollectionView.
The problem is that the method "collecitonView.dequeueRreusableCellWithReuseIdentifier" returns a UICollecitonViewCell. My cell is not that, it is an ASCellNode. So I get an error: "cast from UICollectionViewCell to unrelated type ASNodeCell always fails".
I also get an error at this line:
collection.registerClass(cell1.self, forCellWithReuseIdentifier: "cell1")
The error says "attempt to register a cell class which is not a subclass of UICollectionViewCell."
Is there some other way to work around this? I have searched just about everywhere, but there are very few resources available in Swift (or obj c for that matter) concerning asyncdisplaykit, and I can't find a single example project that uses ASCollectionView. Any help would be appreciated.