开发者

Application Crashes At [context save:&error] (after deleting a record)

开发者 https://www.devze.com 2023-03-01 01:35 出处:网络
I am facing a weird probl开发者_如何学Goem where my application get crashes when delete a record an after that call [context save:&error] method. I get this problem randomly and when it happens, I

I am facing a weird probl开发者_如何学Goem where my application get crashes when delete a record an after that call [context save:&error] method. I get this problem randomly and when it happens, I see no exception on console.

Regards Muhammed Aamir


In Interface file

   @property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController;
   @property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;       

In Implementations File

     @synthesize fetchedResultsController=__fetchedResultsController;
     @synthesize managedObjectContext=__managedObjectContext;
    - (void)dealloc
    {
[__managedObjectContext release];
    [__fetchedResultsController release];
    [super dealloc];
    }

Use this code for delete in a tableview

   NSManagedObjectContext *context = 
    [self.fetchedResultsController managedObjectContext];
    [context deleteObject:[self.fetchedResultsController objectAtIndexPath:indexPath]];

    // Save the context.
    NSError *error = nil;
    if (![context save:&error])
    {
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消