Mac OS X. CoreData app. NSTableView controlled by NSArrayController bound to managed object context for the Country entity. The Country entity has a 'name' attribute and a to-many relationship, 'branches', to a Branch entity. The Branch entity has a 'sales' attribute (an NSNumber).
The NSTableView has two NSTableColumns. The first shows the name of the Country. The second should show the total sales for that Country across all its Branches.
The first column's value is bound to the NSArrayController's arrangedObjects with a model key path of 'name'. No problem there.
The second column's value is bound to the NSArrayController's arrangedObjects with a model key path of 'branches.@sum.sales'. This doesn't work. I get the error message: " addObserver:forKeyPath:options:context:] is not supported. Key path: @sum.sales"
If, instead, I add a 'totalSales' method to my Country class and the method is implemented as follows:
- (NSNumber *)totalSales
{
return [[self branches] valueForKeyPath:@"@sum.sales"];
}
and I then bind the column to 'totalSales' it works fine. My understanding of the Collection Operators documentation is that this should be the same as simply binding to 'branches.@sum.sales'. I can't see why the latter doesn't work. Any ideas? I have seen similar questions in this and other forums, but have yet to see an explanation or solution.