Mac OS X. CoreData Application. An NSTableView managed by NSArrayController is associated with a managed object for a Country object. The essence of the country has the attribute “name” and the relation “many”, “branches”, to branches. The Branch object has the attribute "sales" (NSNumber).
There are two NSTableColumns in NSTableView. The first shows the name of the country. The second should show the total sales for this country in all its branches.
The first column value is bound to NSArrayController objects organized by the model key path to the name. There are no problems.
The second value of the column is tied to NSArrayController objects organized using the "branch. @ Sum.sales" model key path. This does not work. I get an error: "addObserver: forKeyPath: options: context:] is not supported. Key path: @ sum.sales"
If instead, I add the totalSales method to my Country class, and the method will be implemented as follows:
- (NSNumber *)totalSales { return [[self branches] valueForKeyPath:@"@sum.sales"]; }
and then bind the column to 'totalSales', it works fine. My understanding of the Collection Operators documentation is that it should be the same as just binding to "branches". @ Sum.sales. "I don’t understand why the latter does not work. Any ideas? I saw similar questions in this and other forums, but I don’t see any explanations or solutions yet.
source share