objective c - Bind custom control to NSArrayController -


i've subclassed nstextfield create custom control, , want bind property (which nsarray) of custom control nsarraycontroller. don't know how propagate array control nsarraycontroller. key-path i'm using on nsarraycontroller arrangedobjects.name. example, if i'm trying propagate array (@"one", @"two", @"three") , use:

[boundobject setvalue:myarray forkeypath:@"arrangedobjects.name"] 

it set value of each element of arrangedobjects.name array (@"one", @"two", @"three"). want happen have first element in arrangedobjects.name set @"one", second value set @"two", etc.

nstablecolumn this, know it's possible, can't figure out how implemented.

what's best way achieve this?

ok, think may have answered own question. won't mark correct answer right away in case can tell me better way this. way pretty hack.

anyway, reading nsarraycontroller here: http://www.cocoadev.com/index.pl?nsarraycontroller says:

if valueforkeypath:@"arrangedobjects.name" sent array controller, 1 (as expected) gets array of name values, if object replicates behaviour, , table column's value instead bound object, display entire array each row.

and

you bind value of nstablecolumn arrangedobjects.somekey. if try programmatically invoke valueforkeypath:@"arrangedobjects.somekey" on array controller, you'll array resulting invoking valueforkey:@"somekey" on arrangedobjects array -- fine. 1 think nstablecolumn's value can bound objects somearray.somekey, not work (on several levels).

so sounds nstablecolumn special cases bindings nsarraycontroller , arrangedobjects why works right way, , custom control doesn't.

this doesn't seem flexible, it's way can find make work. implemented special case in bindings nsarraycontroller , arrangedobjects , able make work wanted.

a better solution appreciated, though!


Comments

Popular posts from this blog

sql server - python to mssql encoding problem -

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -