Application Crashes At [context save:&error] (after deleting a record)
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();
}
精彩评论