0
我想从我的JSON树下,火力地堡一些价值观但是我得到错误:转换火力地堡值(INT)为String导致错误
Could not cast value of type '__NSCFNumber' (0x1a7c497f0) to 'NSString' (0x1a7c55398).
我设置的值的方式是这样的:
let values = ["username": username, "email": email, "reputation": reputation] as [String : Any]
我得到这样的值:
self.databaseRef.child("users").child(self.loggedInUser!.uid).observeSingleEvent(of: .value) { (snapshot:FIRDataSnapshot) in
//store the logged in users details into the variable
print(self.loggedInUser)
let snapshot = snapshot.value as! [String: AnyObject]
self.usernameLabel.text = snapshot["username"] as! String
self.reputationLabel.text = snapshot["reputation"] as! String//This is giving me error
})
我做错了吗?这是什么造成的?在Swift 2中它工作,但不在Swift 3中。