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中。