ios – 从Parse Cloud更新解析本地存储中的固定PFObject

通过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的新分数数组固定来更新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,但您仍然可以固定此对象而不成功保存它.但是,在成功将其保存到云之前,您无法找到或获取它们.因此,在代码中,您必须将这些特定的PFObject解释出来并以其他方式更新它们或者根本不更新它们.

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...