从 Parse Cloud 更新 Parse Local Storage 中固定的 PFObject
Update pinned PFObject in Parse Local Storage from Parse Cloud
到 object.saveEventually()
,我将能够将本地存储中的数据与 Parse 中的云同步。
但这是我感到困惑的地方,在文档中,它声明:
When an object is pinned, every time you update it by fetching or
saving new data, the copy in the local datastore will be updated
automatically
但是,下一个示例,几段之后,取消固定所有对象,然后通过固定名称为 HighScores
的新 scores
数组来更新 HighScores
PFQuery *query = [PFQuery queryWithClassName:@"GameScore"];
[query orderByDescending:@"score"];
// Query for new results from the network
[[query findObjectsInBackground] continueWithSuccessBlock:^id(BFTask *task) {
return [[PFObject unpinAllObjectsInBackgroundWithName:@"HighScores"] continueWithSuccessBlock:^id(BFTask *ignored) {
// Cache the new results.
NSArray *scores = task.result;
return [PFObject pinAllInBackground:scores withName:@"HighScores"];
}];
}];
因此,我是否应该取消固定 HighScores
的所有对象以更新 HighScores
中的现有分数?
findObjectsInBackground
是否会自动更新已找到的任何固定对象?我很困惑。
谢谢!
我发现 findObjectsInBackground
和 fetchAllInBackground
都会更新任何匹配 objectId
的固定对象。
也就是说,当你最初创建一个对象时,它不会有一个objectId
,但你仍然可以在没有成功保存的情况下固定这个对象。但是,在成功将其保存到云之前,您不能 find
或 fetch
它们。所以在代码中,你必须挑选出这些特定的 PFObjects
并以其他方式更新它们或者根本不更新它们。
到 object.saveEventually()
,我将能够将本地存储中的数据与 Parse 中的云同步。
但这是我感到困惑的地方,在文档中,它声明:
When an object is pinned, every time you update it by fetching or saving new data, the copy in the local datastore will be updated automatically
但是,下一个示例,几段之后,取消固定所有对象,然后通过固定名称为 HighScores
scores
数组来更新 HighScores
PFQuery *query = [PFQuery queryWithClassName:@"GameScore"];
[query orderByDescending:@"score"];
// Query for new results from the network
[[query findObjectsInBackground] continueWithSuccessBlock:^id(BFTask *task) {
return [[PFObject unpinAllObjectsInBackgroundWithName:@"HighScores"] continueWithSuccessBlock:^id(BFTask *ignored) {
// Cache the new results.
NSArray *scores = task.result;
return [PFObject pinAllInBackground:scores withName:@"HighScores"];
}];
}];
因此,我是否应该取消固定 HighScores
的所有对象以更新 HighScores
中的现有分数?
findObjectsInBackground
是否会自动更新已找到的任何固定对象?我很困惑。
谢谢!
我发现 findObjectsInBackground
和 fetchAllInBackground
都会更新任何匹配 objectId
的固定对象。
也就是说,当你最初创建一个对象时,它不会有一个objectId
,但你仍然可以在没有成功保存的情况下固定这个对象。但是,在成功将其保存到云之前,您不能 find
或 fetch
它们。所以在代码中,你必须挑选出这些特定的 PFObjects
并以其他方式更新它们或者根本不更新它们。