以下のコードは、エンティティを削除しません。「削除に成功しました」というメッセージがコンソールに表示されるので、エンティティが見つかります。私が使用する他のすべての操作は成功します。
RestKit 0.20 を使用しています。
NSManagedObjectContext *context = [RKManagedObjectStore defaultStore].mainQueueManagedObjectContext;
NSError *error = nil;
NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity: [NSEntityDescription entityForName:@"Auction" inManagedObjectContext:context]];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"AuctionID = %d", auctionID];
[fetchRequest setPredicate:predicate];
NSArray *result = [context executeFetchRequest:fetchRequest error:&error];
if(result.count) {
Auction *block = result[0];
[context deleteObject:block];
BOOL status = [context save:&error];
if (status == NO) {
NSLog(@"delete falied for AuctionID:%d, error: %@", auctionID, error);
}
else {
[context processPendingChanges];
NSLog(@"delete was successful for AuctionID:%d", auctionID);
}
}
この削除操作が成功しない理由と、それを機能させるための解決策は何ですか。