I'm getting the following error after upgrading to iOS 14. I'm using a library called MessageKit that this is built with.
While preparing update a visible view at <NSIndexPath: 0xd92d17177ece800a> {length = 2, path = 25 - 0} wasn't found in the current data model and was not in an update animation
Does anyone know what this error means? The crash is pointing to the method scrollToBottom
on the collection view. Looks like for whatever reason the last item in the model isn't there anymore when it's running an animation or something. I'm wondering if it could be due to the typing indicator, but I'm not sure.
func insertMessage(_ message: NewMessageModel) {
// Reload last section to update header/footer labels and insert a new one
DispatchQueue.main.async {
self.isPerformingBatchUpdates = true
self.messagesCollectionView.performBatchUpdates({
self.messages.append(message) //The messages object can only be modified on the main thread
self.checkLastMessageSent(message: message)
self.messagesCollectionView.insertSections([self.messages.count - 1])
if self.messages.count >= 2 {
self.messagesCollectionView.reloadSections([self.messages.count - 2])
}
}, completion: { [weak self] _ in
self?.messagesCollectionView.scrollToBottom(animated: true)
self?.isPerformingBatchUpdates = false
})
}
}