I've been receiving a crash report from crashlytics-
Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation
0x9e48 __exceptionPreprocess 1 libobjc.A.dylib 0x178d8 objc_exception_throw 2 Foundation 0x54594c _userInfoForFileAndLine 3 UIKitCore 0x310db4 -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:collectionViewAnimator:] 4 UIKitCore 0x2703c8 -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:animator:animationHandler:] 5 0xd1a0dc
I am sharing a piece of code responsible for the crash, Although my collectionview have a huge code
collectionView.performBatchUpdates({
self.marketBatchUpdates(selectedOrderType: selectedOrderType)
}, completion: nil)
private func marketBatchUpdates(selectedOrderType: BrokerageTradingOrderTypeV2) {
let wasShowingSubmitButton = self.shouldShowSubmitButton()
if selectedOrderType != .Market {
if selectedOrderType == .Stop {
self.selectedOrderType = .Market
if self.showStopDisclosure == true {
collectionView.deleteItems(at: stopOrderDisclosureIndexPaths())
}
}
self.selectedOrderType = .Market
if selectedOrderType == .Limit || selectedOrderType == .StopLimit {
if self.selectedTerm == .DAY || self.selectedTerm == .GTC || self.selectedTerm == .SELECT {
collectionView.deleteItems(at: qualifierIndexPaths())
}
}
self.selectedTerm = .DAY
collectionView.reloadItems(at: termIndexPaths())
}
self.selectedOrderType = .Market
collectionView.reloadItems(at: orderTypeIndexPaths())
self.showOrderTypeSelections = false
collectionView.deleteItems(at: selectionsIndexPaths())
self.updateSubmitButton(previousSubmitButtonState: wasShowingSubmitButton)
}