objective c - How to change the value of an item when other item changes in NSTableView? -
i have populated nstableview using binding nsarraycontroller
https://www.dropbox.com/s/igx8ttdfvi2tt09/ss.png
now when user changes 480 (in column width) 240 want change height value 270 185 accordingly.
what correct way this?
can help?
thanks
anand
just override setters each height , width , change other's value.
in other words, if both height , width properties of same object, have setheight
call setwidth
, etc.
the easiest way if have third property reflects relationship wish height , width have, such aspectratio
.
alternately overriding setters, if want calculation based on previous value of height or width, register kvo changes in both keypaths options:(nskeyvalueobservingoptionnew | nskeyvalueobservingoptionold)
, in observevalueforkeypath
you'd change dictionary both old , new values, calculate how user scaled value , scale other value accordingly (while careful avoid triggering kvo when doing so). see registering kvo observing in kvo programming guide. kvo more difficult , prone error, i'd avoid , maintain consistency in data model through overriding setters.
Comments
Post a Comment