下面是如何保存用戶的例子:如果你需要更多的數據保存到用戶的表,那麼你可以做到這一點也
PFUser.currentUser().setObject(result["email"], forKey: "email")
PFUser.currentUser().setObject(result["name"], forKey: "name")
PFUser.currentUser().setObject(result["gender"], forKey: "gender")
PFUser.currentUser().setObject(result["city"], forKey: "city")
PFUser.currentUser().setObject(result["zipCode"], forKey: "zipCode")
PFUser.currentUser().saveInBackgroundWithBlock {
(success: Bool!, error: NSError!) -> Void in
if (success != nil) {
println("GOOD JOB!")
} else {
println("BAD NEWS!: \(error)")
}
}
,它的工作原理是這樣的:
這是從解析的網站和它的當前,你這是怎麼更新對象所以基本上你會更新用戶表中的條目,你只是添加一列:
var query = PFQuery(className:"GameScore")
query.getObjectInBackgroundWithId("xWMyZEGZ") {
(gameScore: PFObject?, error: NSError?) -> Void in
if error != nil {
println(error)
} else if let gameScore = gameScore {
gameScore["cheatMode"] = true
gameScore["score"] = 1338
gameScore.saveInBackground()
}
}
https://parse.com/docs/ios/guide
有沒有錯誤?用途是否已登錄? – Wain