I am trying to delete some objects from my Entity Reservation
. I am doing it like this.
NSManagedObjectContext *context = reservation.managedObjectContext;
[context deleteObject:reservation];
NSError *error = nil;
if (![context save:&error]) {
NSLog(@"Error is %@",error);
}
After that I delete my object I fetch the whole entity
again. I can see that the object is delete from my entity
. But when I restart my app, all my objects that I deleted in the previous session are back stored in my entity
.
I'm using restkit
to store my objects that I got back from a webservice. Also when I delete the object, I delete it also in my database.
When I restart my app and look at my logs I see that I don't get the object back from my webservice that I deleted in the previous session, so that's oké. The only problem is that they are somehow stored back in my core database
.
I am not entirely sure how reskit handles saving/deleting on threads but basically when you setup your NSManagedObjectContext on the main thread you register for notifications.
If a change to context happens on a background thread then a notification will be sent.