Redwood
Redwood

Reputation: 69322

Is it possible to have a binding that combines more than one key path?

Lets say I have an object which has a quantity value.

Also, I have an array controller which holds an array of these objects.

Furthermore, I have a table which has a percent of total column (i.e. the given row's quantity's percentage of the sum of the quantities for all rows), which needs to be populated with the proper value via bindings.

It would then seem that the idea way to do this would be to bind this column to [email protected] divided by arrayController.arrangedObjects.quantity.

Is it possible to do this?

If not, can you suggest an alternative means of achieving this same end?

Upvotes: 0

Views: 187

Answers (1)

Peter Hosey
Peter Hosey

Reputation: 96363

One way would be to implement a custom number formatter, with a custom binding for the divisor, programmatically bound to arrayController.arrangedObjects.quantity. In the formatter's setObjectValue: method, you would perform the division and pass the result to super.

Upvotes: 1

Related Questions