所以,我有这一块是想从数据库中提取用户,并将其存储在一个阵列(drivingUsers)代码。 我没有得到任何错误,但是当我运行该应用程序崩溃。
func fetchUser() {
FIRDatabase.database().reference().child("user_profiles").observe(.childAdded, with: { (snapshot) in
if let dictionary = snapshot.value as? [String: AnyObject] {
let user = User()
user.setValuesForKeys(dictionary) //Error
self.drivingUsers.append(user)
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}, withCancel: nil)
}
错误日志:
2017-04-29 00:41:46.842568 VEXI[1745:369755] -[__NSCFNumber length]: unrecognized selector sent to instance 0x174a34500
2017-04-29 00:41:46.844084 VEXI[1745:369755] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0x174a34500'
有任何想法吗?