Cocoa bindings - get @sum for an attribute for all children

蓝咒 提交于 2019-12-12 00:36:41

问题


I've been trying to get this to work for a while now.

In my Core Data model I have:

Entity Company has a one to many relationship with Employee (employees)

Company.employees
Employee.age

Using bindings I would like to show the sum of age for all employees when clicking on a Company in a tableView.

I've tried variations of: @distinctUnionOfSets.employees.@sum.age, but can't get it to work.
When I try the above I get the error message: [<_NSFaultingMutableSet 0x10019c430> removeObserver:forKeyPath:] is not supported. Key path: @sum.age

My NSArrayController is bound to Client so in IB it looks like this: Clients.selection.@distinctUnionOfSets.employees.@sum.age

Any ideas?


回答1:


I made this more complicated than it was. Added a new NSArrayController which was bound to Employee.



来源:https://stackoverflow.com/questions/18333711/cocoa-bindings-get-sum-for-an-attribute-for-all-children

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!