Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone & Core Data - Removing NSManagedObject?

I'm trying to remove a managed object context, but instead of removing the object itself it sets all instant variables to null. Am I doing anything wrong while deleting an instant of NSManagedObjectContext?

@implementation MyManagedObject

- (BOOL)submitToServer
{
     if (/*submitted successfully*/)
     {
          return YES;
     }
     else
     {
          [self.managedObjectContext deleteObject:self];
          return NO;
     }
}

@end
like image 305
aryaxt Avatar asked Nov 20 '10 00:11

aryaxt


1 Answers

You must call [self.managedObjectContext save:nil] after deleteObject for the delete to be committed to the persistent store. Read more about deleting a managed object.

like image 198
ma11hew28 Avatar answered Oct 17 '22 03:10

ma11hew28