stack overflow community. Please don't mark this question as a duplicate as I have seen all the other posts regarding this and have pretty much gone through most of the famous solutions.
Currently, I have some code that allows a user to send messages to a group and also change the group thumbnail and title. However, upon the user doing any of this, my code crashes. I am storing my data in firebase (the data is being successfully uploaded). The problem began when I upgraded from swift 3 to swift 4. Also, this is the specific error I am getting:
libc++abi.dylib: terminating with uncaught exception of type NSException
Here are some solutions/methods I have tried to solve my problem:
- I have outruled that this is an outlet problem as the view controller is programmatically created.
- I tried adding an exception breakpoint but it didn't show me any specific lines of code for where the crash occurred.
- I have also tried cleaning, re-building, and closing Xcode however that doesn't work as well.
- I don't think its a problem with uploading data to firebase as I am able to in other parts of my app.
- I have also tried scrolling through the threads to get a deeper understanding of where the crash occurs, however that has not been of much help.
Here is a picture of my console output:
Here is the code I use to update the collection view:
func observeConversationMessagesWithConversationId(conversationId: String) {
Database.database().reference().child("conversation-messages").child(conversationId).observe(.childAdded, with: { (snapshot) in
if let messages = ConversationMessages(snapshot: snapshot) {
self.conversationMessages.append(messages)
DispatchQueue.main.async(execute: {
self.collectionView?.reloadData()
let indexPath = NSIndexPath(item: self.conversationMessages.count - 1, section: 0)
self.collectionView?.scrollToItem(at: indexPath as IndexPath, at: .bottom, animated: true)
})
}
}, withCancel: nil)
}
Here is my podfile
Any help would be appreciated. Please note that I would have added some code but I have no clue where the error occurs.