I'm getting this weird error from Core Date and I cant understand why.
The code below is executed when I delete a row of a UITableView.
I pass a string and an object to the method below and it fetches the article in a database table that has that string and has a foreign key to that object. Then I delete that object and reload the table.
- (void)deleteFavorite:(NSString *)link inFolder:(Favorites *)f { NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *favsDecriptor = [NSEntityDescription entityForName:@"Favorites" inManagedObjectContext:context]; [request setEntity:favsDecriptor]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(belongsTo == %@) AND (link = %@)", f, link]; [request setPredicate:predicate]; NSError *error = nil; NSMutableArray *fav = [[NSMutableArray alloc] init]; fav = [[context executeFetchRequest:request error:&error] retain]; if (![context save:&error]) { NSLog(@"Cannot fetch the story from the fetch request."); } NSLog([[fav objectAtIndex:0] title]); error = nil; [context deleteObject:[fav objectAtIndex:0]]; if (![context save:&error]) { NSLog(@"Can't delete the fav! %@", error); } }
The app instantly crashes and I get this message in the console. But when I launch the app afterwards, the row has been deleted.
Detected an attempt to call a symbol in system libraries that is not present on the iPhone: _Unwind_Resume called from function _PFFaultHandlerLookupRow in image CoreData.
Please help!
Thanks in advance to everyone!