3
votes


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!

2

2 Answers

2
votes

This is probably related to a bug within Core Data itself. I had the same error come up (I asked about it here in SO) and my only fix was to change the keywords in the predicate that still allowed the same results. It took some experimenting to find the right combination. Not ideal, but that's the best answer I can offer based on my experience.

2
votes

Is it possible that you are holding a reference to the delete object or that the deleted object is an observer and is getting a callback after its been deleted? I had something similar to this recently, though slightly different error message. In my case, I also crashed upon deletion (under some conditions) but when I relaunched the object-to-be-deleted had, in fact, been deleted.

If you haven't already done so, under the Run menu select Stop on Objective-C Exceptions. This helped me track down the root cause of my crash. In my case it was KVO observer getting callback of change of value of a property of deleted NSManagedObject.