解析saveInBackground

时间:2014-04-14 20:05:05

标签: objective-c parse-platform

我有一个名为relationship的班级,其read列的类型为Boolean

relationship[@"read"] = @YES;
[userToMessageRelationship saveInBackground];

这只适用于当时的 某些 ,但考虑到我的应用的性质,它在100%的时间内工作非常重要。我不确切知道saveInBackground是如何工作的,但Parse API中有一种不同的方法可以保存更可靠的值。

我能想到的唯一可能是导致这种反复无常的行为的是我通过NSArchiverthis api提供的NSCoding来保存关系。然后我用NSUnarchiver从文件中加载它。我不知道为什么这会影响saveInBackground虽然......

1 个答案:

答案 0 :(得分:0)

对于布尔值,请使用

relationship[@"read"] = [NSNumber numberWithBool:YES]

saveInBackground始终有效,但您可以使用saveInBackgroundWithBlock添加一些在保存失败时触发的代码:

[object saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        // Test for succeeded or error here
    }];
相关问题