当我打开模拟器并单击聊天室时,出现以下错误:线程1:致命错误:在展开一个可选值时意外发现nil
代码:
@IBAction func sendButton(_ sender: Any) {
self.chatTextfield.resignFirstResponder()
if !chatTextfield.text!.isEmpty {
if let user = Auth.auth().currentUser {
DataService.dataService.CreateNewMessage(userId: user.uid, roomId: roomId, textMessage: chatTextfield.text!)
} else {
// No user signed in!
}
self.chatTextfield.text = nil
} else {
print("Error: Empty")
}
}