简体   繁体   中英

Core Data Annotation - Repairing Missing Delete Propagation

I have a program that works perfectly fine. No crash, no bug or anything, but when it comes to deleting an NSManagedObject, the following message appears in the console.

Core Data: annotation: repairing missing delete propagation for to-one relationship

And then, some details about the relationship.

Once again, this does not make the app crash and the program goes on running as expected, but still, that makes me worried. Should I do something about it or is it alright to have some annotations from Core Data?

Thanks in advance :)

You should adopt a better strategy on deletion.

  1. Go to your .xcdatamodeld, select the concerned relationship
  2. Select your entity and relationship using an inverse relation
  3. Choose what to do on Delete Rule

    在此输入图像描述

You must save context after deleting a managed object.

After deleting something:

AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSError *error;
if (![appDelegate.managedObjectContext save:&error]) {
    NSLog(@"Error in Appdelegate>getLocalVersionAddFirstVersion");
}

Just as a new object is not saved to the store until the context is saved, a deleted object is not removed from the store until the context is saved. ( Apple Documentation )

我有同样的问题,一旦我为相关关系添加了反比关系 ,它就消失了。

For me it was a slightly different problem: there was an orphan detection in place that removed the newly created object right away when it was saved, because I forgot to add the new parent relationship to the isOrphan() function. Strangely enough it lead to exactly this error ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM