gpt4 book ai didi

ios - 从 Parse Cloud 更新 Parse Local Storage 中固定的 PFObject

转载 作者:IT王子 更新时间:2023-10-29 05:53:05 26 4
gpt4 key购买 nike

通过 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/p>

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 是否会自动更新任何找到的固定对象?我很困惑。

谢谢!

最佳答案

我发现 findObjectsInBackgroundfetchAllInBackground 都会更新任何与 objectId 匹配的固定对象。

也就是说,当你最初创建一个对象时,它不会有objectId,但你仍然可以在没有保存成功的情况下固定这个对象。但是,在成功将其保存到云端之前,您无法查找获取 它们。因此,在代码中,您必须挑选出这些特定的 PFObjects 并以其他方式更新它们,或者根本不更新它们。

关于ios - 从 Parse Cloud 更新 Parse Local Storage 中固定的 PFObject,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28169045/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com