我编写了一个使用Parse.com的iOS应用程序。当我需要更改有关用户的信息时,我使用refreshInBackgroundWithBlock
。我现在正在为Mac OS X编写应用程序,但我似乎无法使用refreshInBackgroundWithBlock
。有什么建议吗?
以下是代码。
//Refresh the User Info
currentUser.refreshInBackgroundWithBlock { (object, error) -> Void in
//Fetch the User Info
currentUser.fetchIfNeededInBackgroundWithBlock { (result, error) -> Void in
//Check if the comments read is nil
if object.objectForKey("commentsRead") === nil {
println("Comments Read is empty")
} else {
var currentRead:[Int] = []
//If not empty assign the array to the value
currentRead = object.objectForKey("commentsRead") as Array
currentRead.append(0)
var user = PFUser.currentUser()
user.setObject(currentRead, forKey: "commentsRead")
user.saveInBackgroundWithBlock { (result, error) -> Void in
println("Completed!")
}
}
答案 0 :(得分:2)
根据解析文档,refreshInBackgroundWithBlock
已被弃用,取而代之的是fetchInBackgroundWithBlock
(See this)
因此,您不需要致电refreshInBackgroundWithBlock
。