Post

Replies

Boosts

Views

Activity

Reply to Crash, UICollectionView: Snapshot when updating data.
  0x7fff5108634a <+522>: callq  0x7fff510866d0            ; closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift.assertionFailure(: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never >  0x7fff5108634f <+527>: addq   $0x20, %rsp. - [Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value]     0x7fff51086353 <+531>: ud2         0x7fff51086355 <+533>: movl   %r14d, %ecx     0x7fff51086358 <+536>: shrl   $0x6, %ecx     0x7fff5108635b <+539>: movl   %r14d, %eax     0x7fff5108635e <+542>: andl   $0x3f, %eax     0x7fff51086361 <+545>: shll   $0x8, %eax     0x7fff51086364 <+548>: cmpl   $0x800, %r14d             ; imm = 0x800      0x7fff5108636b <+555>: jae    0x7fff51086391            ; <+593>     0x7fff5108
Jun ’20
Reply to Crash, UICollectionView: Snapshot when updating data.
Sure. First, I thought that I knew why I was getting the 'force-unwrap' crash following the breakpoints for the crash in that I was using the following: var dataSource: UICollectionViewDiffableDataSource<Section, RandomData>!. So, I changed the code to typealias DataSource = UICollectionViewDiffableDataSource<Section, RandomData>. I am still getting a "force-unwrap" crash. Here are both methods that I am seeing the respective crash when calling the method from a modal VC. NOTE: The data loads / displays fine on initial load, but crashes when attempting to add new data. Method #1: func updateData(for testData: [RandomData]) { var snapshot = NSDiffableDataSourceSnapshot<Section, RandomData>() snapshot.appendSections([.main]) snapshot.appendItems(testData) // Crash on dataSource apply method when calling from anotehr VC. DispatchQueue.main.async { self.dataSource.apply(snapshot, animatingDifferences: true, completion: nil) }} Method #2 func makeDataSource() -> DataSource { // Crash on dataSource apply method when calling from anotehr VC. let dataSource = DataSource(collectionView: collectionView) { (collectionView, indexPath, testData) -> UICollectionViewCell? in // let cell = collectionView.dequeueReusableCell(withReuseIdentifier: PerscriptionCell.reuseID, for: indexPath) as? RandomDataCell cell?.set(dataType: testData) return cell		} 		return dataSource 		 } Thank you, Paul
Jun ’20