Database master data not working

I am the first user / student of Core Data for iPhone, I thought I [managedObjectContext save:$error]was used to save changes to the Persistant repository.

But when I reload and call NSFetch, the objects are still there. Any ideas why?

for (int i ; i < [mutableFetchResults count];i++)
{
    NSManagedObject *toDelete = [mutableFetchResults objectAtIndex:i];
    [managedObjectContext toDelete];

    // Update the array and table view.
    [mutableFetchResults removeObjectAtIndex:i];
}


if (![managedObjectContext save:&error]) {
    // Handle the error.
    NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
    exit(-1);  // Fail
}
+3
source share
1 answer

I expected to see the line where you are removing the object from the managed object:

[manageObjectContext deleteObject:toDelete];

Assuming that manageObjectContext is your context, and toDelete is a managed object in your context or mutableFetchResults.

Then I expected to see the save right after that.

+6
source

Source: https://habr.com/ru/post/1769444/


All Articles