Programmatically determine keys in an controller
Programmatically determine keys in an controller
- Subject: Programmatically determine keys in an controller
- From: Greg Hurrell <email@hidden>
- Date: Tue, 26 Apr 2005 22:44:03 +0200
If you select an NSArrayController in Interface Builder you will see
a listing of "Keys" in the inspector window. For example, if you bind
the value of an NSTableColumn to the controller with a keypath of
"arrangedObjects.myKeyPath", then you'll see "myKeyPath" in the
controller's inspector.
Is there any way to programmatically query an NSArrayController at
runtime to get that listing of keys?
At the moment the only way I can see to get this information is to
subclass the NSTableColumn bound to the controller, override the
bind:toObject:withKeyPath:options: method, and extract the key from
the key path there. But the controller must also know the key path,
otherwise it wouldn't appear in the inspector, so I'd like to figure
out how to ask the controller for the list of keys...
Snooping with class-dump shows this undocumented method in NSController:
- (id)_declaredKeys;
And it does indeed return the same list of keys that the Interface
Builder inspector shows. It's awfully tempting to use this method
even though it's not documented, but I am worried about possible
future code breakage and am hesitant to use it in a shipping app. Any
comments or ways to achieve the same result without resorting to
undocumented methods?
Cheers,
Greg
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden