核心数据 NSFetchedResultController 未在对象更改时更新?
我有一个带有此谓词集的 NSFetchedResultController:
NSPredicate* pred = [NSPredicate predicateWithFormat:@"author != %@ && deleted != %@", [NSNumber numberWithLongLong:0],[NSNumber numberWithBool:YES]];
它在启动时过滤得很好,如果添加或删除对象,我会得到一个委托回调并列表更新。
但是,如果我更改“已删除”字段,则 NSFetchedResultController 集不会更新,也不会收到回调。
虽然 NSFetchedResultController 中的实际对象已更新,但如果我在表上执行“reloadData”并检查“deleted”的值,它实际上设置为 YES。
为什么它没有从 NSFetchedResultController 中消失?
这是预期的行为吗? 或者我可能做错了什么?
I have a NSFetchedResultController with this predicate set:
NSPredicate* pred = [NSPredicate predicateWithFormat:@"author != %@ && deleted != %@", [NSNumber numberWithLongLong:0],[NSNumber numberWithBool:YES]];
It filters fine on startup, and I get a delegate callback and list updates fine if objects are added or deleted.
But if I change the "deleted" field, the NSFetchedResultController set is NOT updated, nor do I get the callback.
Though, the actual object in the NSFetchedResultController is updated, if I do a "reloadData" on my table and check the value of "deleted", it is actually set to YES.
Why is it not disappearing from the NSFetchedResultController?
Is this expected behavior?
Or what could I be doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我解决了它......
事实证明我确实得到了回调(“didChangeObject”),现在我在这里检查“deleted”的值,如果该值为 YES,则手动将其从 NSFetchedResultController 中删除。
似乎有效,但我仍然希望它是自动的。
I guess I solved it...
Turns out I actually do get the callback ("didChangeObject") and I now check the value of "deleted" here and manually remove it from the NSFetchedResultController if the value is YES.
Seems to work, but I still did expect it to be automatic.