【问题标题】:Cannot use removeObjectForKey in Parse (using Back4App on Objc)无法在 Parse 中使用 removeObjectForKey(在 Objc 上使用 Back4App)
【发布时间】:2017-12-13 01:10:28
【问题描述】:

我正在使用 Back4App 的服务来托管 Parse 服务器,但我似乎无法成功地从一行中删除一个字段。有问题的字段是指向另一个对象的指针,调用 removeObjectForKey 后保存不起作用。其他更新在同一批次中工作,我已经看到我尝试过的 36 次中有 4 次,它确实成功删除了该对象。

[self.myProfile removeObjectForKey:@"partnership"];
[self.myProfile saveEventually:^(BOOL succeeded, NSError * _Nullable error) {
    NSLog(@"success %d", succeeded);  //always returns true
}];

这是 Back4App 的一个已知问题吗?还是解析自己?我在swift中尝试了相同的代码并且它有效。

有什么想法吗?

【问题讨论】:

    标签: objective-c parse-platform back4app


    【解决方案1】:

    当您需要运行回调,确认何时被删除时,推荐使用 deleteInBackgroundWithBlock: 或 deleteInBackgroundWithTarget:selector: 方法。您可以使用 removeObjectForKey 方法从对象中删除单个字段:

    // After this, the playerName field will be empty
    [classScore removeObjectForKey:@"customName"];
    
    // Saves the field deletion to the Parse Cloud
    [classScore saveInBackground];
    

    关于保存最终,大多数保存功能会立即执行,并在保存完成时通知您的应用。如果您不需要知道保存何时完成,您可以使用 saveEventually 代替。好处是如果用户当前没有网络连接。

    来自 Parse 的内容 =D

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-19
      • 1970-01-01
      相关资源
      最近更新 更多