更改核心数据中托管对象模型的属性值时崩溃

发布于 2024-10-21 01:40:40 字数 634 浏览 2 评论 0原文

我有一个表视图控制器,它使用每行的获取结果控制器来获取项目。当选择一行时,它会推送一个新的视图控制器来编辑该特定的托管对象模型 - 当我编辑并尝试保存时,我会得到以下内容。原因是什么? 谢谢

Serious application error.  Exception was caught during Core Data change processing.  This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification.  Can't use in/contains operator with collection 0 (not a collection) with userInfo (null)
Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
_Unwind_Resume called from function -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] in image CoreData

I have a table view controller which fetches items using fetched results controller for each row. When a row is selected it pushes a new view controller to edit that particular managed object model - when I edit and try to save I get the following. What is the cause?
Thanks

Serious application error.  Exception was caught during Core Data change processing.  This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification.  Can't use in/contains operator with collection 0 (not a collection) with userInfo (null)
Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
_Unwind_Resume called from function -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] in image CoreData

.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩发小公举 2024-10-28 01:40:40

错误的这一部分:

...Can't use in/contains operator with collection 0 (not a collection)...

通常表示错误的谓词,最有可能是在 fetch 或 fetched 属性上。您很可能尝试在谓词中使用 INCONTAINS 运算符,而不提供目标对象属性可能所在的实际值集合。例如

NSPredicate *p=[NSPredicate predicateWithFormat:@"attribute1 IN %@", @"a string not an array"];

... vs:

NSArray *inCollection=[NSArray arrayWithObjects:@"Tom",@"Dick",@"Harry",nil];
NSPredicate *p=[NSPredicate predicateWithFormat:@"attribute1 IN %@", inCollection];

据推测,您在编辑中更改的内容会破坏表获取中的谓词。您还需要确保已实现获取结果控制器的委托方法,以便在插入、删除或更改对象时,表将正确更新以反映这些更改。

(错误的其余部分无关紧要。这只是一个框架警告,您无能为力。)

This part of the error:

...Can't use in/contains operator with collection 0 (not a collection)...

usually indicates a bad predicate, most likely on a fetch or fetched attribute. You've mostly likely tried to use the IN or CONTAINS operator in a predicate without supply an actual collection of values that the targeted objects attributes could be in. E.g

NSPredicate *p=[NSPredicate predicateWithFormat:@"attribute1 IN %@", @"a string not an array"];

...vs:

NSArray *inCollection=[NSArray arrayWithObjects:@"Tom",@"Dick",@"Harry",nil];
NSPredicate *p=[NSPredicate predicateWithFormat:@"attribute1 IN %@", inCollection];

Presumably, something you are changing in your edit is breaking your predicate in the table's fetch. You also want to make sure you've implemented the fetched results controller's delegate methods so that if an object is inserted, deleted or changed, the table will be properly updated to reflect those changes.

(The rest of the error is irrelevant. It's just a framework warning you can't do anything about.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文