在核心数据中:为什么 arraycontroller view 没有注意到 object.otherobject.property 的变化而只注意到 object.property 的变化?
我有一个 nsarraycontroller * ctrlr1 从核心数据实体 obj1 获取其数据,女巫与 obj2 具有一对一的关系,也由 nsarraycontroller * ctrlr2 获取 在 ctrlr 中,我通过 IB 设置了一个像这样的获取谓词
inactive == 0 && obj2.active ==1
,我有一个带有 obj1 属性绑定属性的视图,如果我单击绑定到非活动状态的复选框,我的 nscollection 视图会正确淡出 obj1 及其视图,但是 如果在另一个 nscollectionview 中我将 obj2 属性 active 更改为 0,即使我强制使用 fetch:
方法,第一个 nscollectionview 也不会立即更新,这可能是什么?首次获取(应用程序启动)时,获取效果完美
I have an nsarraycontroller * ctrlr1 fetching its data from core data entity obj1 witch has a relationship one to one to obj2 also fetched by nsarraycontroller * ctrlr2
in ctrlr i have set via IB a fetch predicate like this
inactive == 0 && obj2.active ==1
I have a view with bound properties for obj1 attributes and if i click the checkbox bound to inactive my nscollection view correctly fades obj1 and its view BUT
If in another nscollectionview I change obj2 attribute active to be 0, the first nscollectionview doesn't get updated istantly even if I force a fetch:
method, what could it be? fetch works perfectly on first fetch (app launch)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NSArrayController 不知道它需要观察可能任意深的对象树,而只是观察被观察数组(以及数组本身)中对象的属性。因此,您需要以编程方式提供更改通知,以将“深层”更改向上冒泡到数组控制器,或者显式告诉控制器观察这些深层关键路径。
The
NSArrayController
doesn't know that it needs to observe a potentially arbitrarily deep tree of objects, and just observes properties on the objects in the observed array (and the array itself). So you'd need to provide a change notification programatically for a "deep" change to bubble up to the array controller, or explicitly tell the controller to observe those deep key paths.