问题
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