问题
I have custom value in a PFUser column called "website"
. I am trying to get this value using the code below but it does not seem to change on the device if I update the value from Parse.com on their website using the data viewer. It also does not update across devices.
Any Ideas?
websiteField.text = currentUser.objectForKey("website") as String
回答1:
I have managed to get it working with the code below.
var currentUser = PFUser.currentUser()
currentUser.refreshInBackgroundWithBlock { (object, error) -> Void in
println("Refreshed")
currentUser.fetchIfNeededInBackgroundWithBlock { (result, error) -> Void in
self.websiteStr = currentUser.objectForKey("website") as String
self.websiteField.text = self.websiteStr
println("Updated")
println(self.websiteStr)
}
}
来源:https://stackoverflow.com/questions/27284575/get-pfuser-object-custom-values