Re: NSKeyValueBinding
Re: NSKeyValueBinding
- Subject: Re: NSKeyValueBinding
- From: mmalc crawford <email@hidden>
- Date: Tue, 15 May 2007 18:38:51 -0700
On May 15, 2007, at 5:43 PM, Development wrote:
I have a custom object that is basically little more than a branch/
leaf node structure. It is used to hold data for display in an
outline view. It only allows a single level. In other words a branch
can only have leaves and no further branches. thus it is an
exceedingly simple structure.
What I am trying to do is Either use the keybindings in IB or make
my own so that I can use [[root children]
sortedArrayUsingDescriptors:desc]; to sort the root directory's
children. (and also to sort any of the children's contents when a
"Sort selected" menu item is clicked.) Well when I try to sort with
that function I get this error in the runlog: [<NodeItem 0x377090>
valueForUndefinedKey:]: this class is not key value coding-compliant
for the key ItemName.
I am assuming this means I need to use the NSKeyValueBinding
No, exactly as the error message states, it simply means that the
target object is not KVC compliant for the given key. It says nothing
about KVB.
I looked for example code and found nothing
The BindingsJoystick example here <http://developer.apple.com/samplecode/BindingsJoystick/
> and the GraphicsBindings example here <http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
> both illustrate how to implement the bind:... method for custom
views.
So what I have not been able to figure out is how to make my
NodeItem class key value coding compliant.
KVC compliance is described in detail here: <http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/Compliant.html
>.
Like I said I just don't understand what I'm reading on the website,
and am not entirely sure the answer I am looking for is there. Does
any one know of an example that does this?
See above.
Of what I have read, I believe I am suppose to use: - (void)bind:
(NSString *)binding toObject:(id)observable withKeyPath:(NSString
*)keyPath options:(NSDictionary *)options to accomplish this
compliance and this is the breakdown... I don't understand the
documentation.
How bindings work is described in detail here <http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/HowDoBindingsWork.html
>.
What I think i understand is: bind:@"ItemName" toObject:NodeItem (i
have no idea if this is right) I am totaly lost when I get to
withkeypath and options.
Again, these are described in the article referred to above.
You appear to be confusing the role of the view with the role of the
controller and your model objects.
Your Node objects probably should not be interested in sort
descriptors. It is typically the role of the controller to apply a
different ordering on the data if such is required.
mmalc
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden