Key-value coding in Cocoa, explained
Posted on October 3, 2005
Filed Under /dev/null/ | 73 views |
This is why I love Cocoa, though I don’t spend nearly enough time in it: Key-Value Coding (KVC) and Generic Programming:
Key-Value Coding (KVC) is a Cocoa protocol for getting and setting values generically. In programming, the term “generically” describes a way of doing things that applies to many different situations.
…
This is where the KVC magic comes in. It will actually find the -setFirstName:, -setLastName:, -setPhoneNumber: and -setEmailAddress: implementations and call those. If it can’t find these, KVC will try quite a few different options before ultimately just setting a value on the instance variable itself.
That, among other things, is sweet.
Comments
Leave a Reply