点击进入聊天室时弹出错误

时间:2018-11-21 19:45:01

标签: swift xcode firebase

当我打开模拟器并单击聊天室时,出现以下错误:线程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")
  }

}

0 个答案:

没有答案