Post

Replies

Boosts

Views

Activity

UICollectionViewDiffableDataSource crashing in Catalyst
Hi all,I created some collection views on an iOS app using UICollectionViewDiffableDataSource which is working great. Any issues I had previously with updates causing fatalErrors when the view and datamodel somehow got out of sync immediately vanished.However, just out of interest I tried my App as a Catalyst App and ran into a problem straight away:Could not cast value of type '__NSDiffableDataSourceSnapshot' (0x7fff9ee8ebd8) to '__UIDiffableDataSourceSnapshot' (0x7fff9ff49980).The error occured on the only line in this function:public func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeContentWith snapshot: NSDiffableDataSourceSnapshotReference) { diffableDataSource.apply(snapshot as NSDiffableDataSourceSnapshot<String, NSManagedObjectID>, animatingDifferences: true) }The UICollectionViewDiffableDataSource is defined as:lazy var diffableDataSource : UICollectionViewDiffableDataSource<String, NSManagedObjectID> = { UICollectionViewDiffableDataSource(collectionView: self.collectionView) { collectionView, indexPath, _ in let cell: ViewCellType = collectionView.dequeueReusableCell(for: indexPath) cell.update(model: self.fetchedResultsController.object(at: indexPath)) return cell } }()It's worth repeating that this works perfectly on iOS so my gut feeling is that this should work on Catalyst. However I'd be surprised if I was the only one attempting to do this so I thought I'd throw it out the community and see if anybody else out there had this working, and if it is because of something I've done differently.I should note that I was unable to find an example (or even any documentation) anywhere from Apple UICollectionViewDiffableDataSource. I did however hear Josh Shaffer say on Swift by Sundell yesterday that they were still hard at work on the documentation.While I'm not looking at making this particular app availabe via Catalyst in the near future, I would really like to see it running.Thanks all,David.
5
0
2.0k
Oct ’19