核心数据错误:_Unwind_Resume从image CoreData中的_PFFaultHandlerLookupRow函数调用

时间:2021-12-26 16:03:20


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.

我从Core Date上得到了这个奇怪的错误,我不明白为什么。当我删除UITableView的一行时,将执行下面的代码。我将一个字符串和一个对象传递给下面的方法,它将获取数据库表中的文章,该表具有该字符串并具有该对象的外键。然后删除该对象并重新加载该表。

- (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.

应用程序立即崩溃,我在控制台收到了这条消息。但当我之后启动app时,行被删除了。

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 个解决方案

#1


2  

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.

这可能与核心数据本身中的bug有关。我出现了相同的错误(我在SO中询问了它),我唯一的修正是修改谓词中的关键字,使其仍然允许相同的结果。需要一些实验才能找到正确的组合。不是很理想,但根据我的经验,这是我能给出的最好的答案。

#2


2  

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.

是否可能您持有一个对delete对象的引用,或者被删除的对象是一个观察者,并且在被删除后正在获得一个回调?最近,我得到了类似的消息,尽管错误信息略有不同。在我的例子中,我也在删除时崩溃(在某些情况下),但是当我重新启动要删除的对象时,实际上已经被删除了。

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.

如果您还没有这样做,请在Run菜单下选择Objective-C异常中的Stop。这帮助我找到了崩溃的根本原因。在我的例子中,KVO observer正在获取被删除的NSManagedObject属性的值变化的回调。

#1


2  

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.

这可能与核心数据本身中的bug有关。我出现了相同的错误(我在SO中询问了它),我唯一的修正是修改谓词中的关键字,使其仍然允许相同的结果。需要一些实验才能找到正确的组合。不是很理想,但根据我的经验,这是我能给出的最好的答案。

#2


2  

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.

是否可能您持有一个对delete对象的引用,或者被删除的对象是一个观察者,并且在被删除后正在获得一个回调?最近,我得到了类似的消息,尽管错误信息略有不同。在我的例子中,我也在删除时崩溃(在某些情况下),但是当我重新启动要删除的对象时,实际上已经被删除了。

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.

如果您还没有这样做,请在Run菜单下选择Objective-C异常中的Stop。这帮助我找到了崩溃的根本原因。在我的例子中,KVO observer正在获取被删除的NSManagedObject属性的值变化的回调。