Re: key value coding sample code
Re: key value coding sample code
- Subject: Re: key value coding sample code
- From: Vince DeMarco <email@hidden>
- Date: Sun, 8 Dec 2002 12:25:26 -0800
On Saturday, December 7, 2002, at 05:52 PM, Joost Rekveld wrote:
Does this help at all, or am I missing your problem completely?
thanks for the reactions so far,
what I understood from the doc is that I have to subclass
NSClassDescription in order to get a list of all keys to which
instances of a certain class respond. (with - attributeKeys, -
inverseRelationshipKey: - toManyRelationshipKeys -
toOneRelationshipKeys)
No NSClassDescription has nothing to do with key value coding, just
look at the examples on the machine.
I don't understand why a separate describing class is a good thing, to
me it seems complicated even though it would be a simple class; why is
it better than having the object itself return such a list ?
Also i don't understand when/how to register such a class description,
would that be part of its 'init' ?
I want to be define a kind of protocol with 'saveState' and 'setState'
as he two most important methods; 'saveState' would make a dictionary
with the important instance variables of an object, 'setState' would
set these. In this way I want to be able to 'animate' objects in a
consistent way...
All key value coding is basically.
there are methods on NSObject
so if you call
aValue = [myObject valueForKey:@"foo"]
the above will get translated "essentially" to
aFunnyValue = [myObject foo]
the only difference is that aValue will get converted to an NSNumber if
aFunnyValue is a int, float or double.
there is also the other side of the part
[myObject takeValue:aValue forKey:@"foo"]
will essentially get converted to
[myObject setFoo:aFunnyValue];
The common thing about the two examples is that aValue is always an
object, and aFunnyValue is whatever.
Does this help??
keyValue coding is basically a way of making all of the object access
look the same.
vince
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.