views:

70

answers:

1

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?

+1  A: 

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.

Peter Hosey