我正在使用iOS 9和Swift 2以及Parse。 我有一个像下面那样的PF对象,提前创建并从解析中拉下来。
{
"history" = [
{
"completed": false,
"date": "December 1, 2015",
"id": "dlxIHMO4lgDecember 1, 201507:15:06"
}
],
"user" = "john doe"
}

我正在尝试将completed
属性更新为true并保存。
var daily = PFObject(className: "Drops")
let query = PFQuery(className: "Drops")
query.whereKey("username", equalTo: PFUser.currentUser()!)
query.getFirstObjectInBackgroundWithBlock {
(object: PFObject?, error: NSError?) -> Void in
if error != nil || object == nil {
print("The getFirstObject request failed.")
} else {
print("Successfully retrieved the object")
daily = object!
(daily["history"][0]).setValue(true, forKey: "completed")
daily.saveInBackgroundWithBlock {
(success: Bool, error: NSError?) -> Void in
if (success) {
print("completion saved in parse")
} else {
print("completion could not be saved in parse")
}
}
}
}
在调试时,属性值看起来更新,但在解析时它显示旧值false。
我不确定我错过了什么!
我还尝试使用daily.saveEventually()
但没有成功。