我想观察我的Firebase数据库中的更改并在我的应用程序中检索它们。不幸的是,我总是遇到这个错误
无法将类型'__NSCFConstantString'(0x10b197760)的值强制转换为'NSDictionary'(0x10b198818)
这是代码
func retrieveData (){
let messageID = Database.database().reference().child("PatientID")
messageID.observe(.childAdded) { (snapshot) in
let snapshotvalue = snapshot.value as! Dictionary <String,String>
let text = snapshotvalue ["MessageBody"]!
let sender = snapshotvalue ["Sender"]!
let dataEntry = DataLog()
dataEntry.MessageBody = text
dataEntry.Sender = sender
self.itemArray.append(dataEntry)
self.tableView.reloadData()
}
}