我正在尝试更新我用 Parse 保存的聊天对象,虽然它有时有效,但并不一致。如果我在浏览器端从数据中清除对象,它将工作几次,但随后我收到错误消息:
Error: object not found for update (Code: 101, Version: 1.3.0)
这是我正在使用的代码,尽管我尝试了很多方法。此代码与 Parse 文档几乎相同。
PFObject *currentChatroom = _currentChatroom;
NSString *objID = currentChatroom.objectId;
PFQuery *query = [PFQuery queryWithClassName:@"Chats"];
// Retrieve the object by id
[query getObjectInBackgroundWithId:objID block:^(PFObject *fetchedChat, NSError *error) {
// Now let's update it with some new data. In this case, only cheatMode and score
// will get sent to the cloud. playerName hasn't changed.
fetchedChat[@"lastTextSent"] = lastTextWithUser;
fetchedChat[@"lastTextSentDate"] = date;
[fetchedChat saveInBackground];
}];
为了更好地衡量,这是 Parse 的建议:
PFQuery *query = [PFQuery queryWithClassName:@"GameScore"];
// Retrieve the object by id
[query getObjectInBackgroundWithId:@"xWMyZ4YEGZ" block:^(PFObject *gameScore, NSError *error) {
// Now let's update it with some new data. In this case, only cheatMode and score
// will get sent to the cloud. playerName hasn't changed.
gameScore[@"cheatMode"] = @YES;
gameScore[@"score"] = @1338;
[gameScore saveInBackground];
}];
该代码有时会起作用,所以我知道这不是问题所在。我只是不确定是什么。