On 3 Oct 2009, at 20:20, Colin Howarth wrote:

OK, skipping the melodrama, there's something wrong with the Apple documentation,
but I can't quite put my finger on it.

The Perl man pages on nested data structures, say a dictionary containing arrays containing other dictionaries which are actually representing objects, I find perfectly clear, for example.
And I did the first time I read it.

Take the Key-Value Coding Programming Guide which describes the NSKeyValueCoding informal protocol which defines a mechanism allowing applications to access the properties of an object indirectly by name (or key), rather than directly through invocation of an accessor method or as instance variables.

Translation: You'll find lots of useful things can happen if you access your instance variables (e.g. the variable bar of the instance foo) like this: baz = foo.bar; foo.bar = baz; which is just shorthand for baz = [foo bar]; and [foo setBar: baz]; . Other parts of your code can access bar simply
by knowing the string @"bar".

Actually, that's not a translation, it's more or less (less rather than more, I admit) the entire Key-Value
Coding Programming Guide. At least, it's enough to get you going.

Well for a start your translation is wrong. Being able to do this:

baz = foo.bar;
foo.bar = baz;

is an Objective-C 2.0 feature – Dot Notation. It is completely orthogonal to Key-Value Coding.

Dot Notation works by the compiler figuring out which method calls the dots correspond to.

Key-Value Coding happens at run-time where the object receives a - valueForKey: or -setValue:forKey: message and then decides how to handle it based upon the key.

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to