0
因此...這段代碼在幾天前工作,但我更新了我的Parse窗格,現在我無法保存新創建的對象。該錯誤告訴我,該對象沒有找到更新,但我甚至沒有嘗試更新現有的對象 - 我正在創造新的。iOS - 解析創建新對象 - 找不到更新對象
這裏是我的代碼:
PFUser *owner = [self.item objectForKey:@"user"];
PFUser *lendee = [PFUser currentUser];
PFObject *newRequest = [PFObject objectWithClassName:@"ItemRequest"];
[newRequest setObject:owner forKey:@"owner"];
[newRequest setObject:lendee forKey:@"lendee"];
[newRequest setObject:self.item forKey:@"item"];
[newRequest saveInBackgroundWithBlock:^(BOOL succeeded, NSError * _Nullable error) {
if (error) {
NSLog(@"Error with saving: %@", error);
} else {
NSString *message = [NSString stringWithFormat:@"%@ has requested to borrow your %@", [lendee objectForKey:@"full_name"], [self.item objectForKey:@"title"]];
[PFCloud callFunctionInBackground:@"sendEmailToUserWithId"
withParameters:@{@"userId" : owner.objectId,
@"subject" : message,
@"message" : message}
block:^(id _Nullable object, NSError * _Nullable error) {
if (error) {
NSLog(@"Failed to send email with error: %@", error);
}
}];
}
}];
任何想法?
不幸的是,所有的項目都有一個objectId。這個問題在我更新Parse之後開始發生,我的數據庫沒有改變,owner或者self.item也沒有改變。 –