Tutorial :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 arrayController.arrangedObjects.@sum.quantity divided by arrayController.arrangedObjects.quantity.

Is it possible to do this?

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


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.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »