Key Value Coding 2: valueForUndefinedKey

Download and open up KVO2. Confusingly the folder it is in is called KVO2, but the project is called KVO1. C'est la vie. Changing application and project names in XCode is difficult and error prone, so I did not bother. The window does have a new name, however.

KVO1 had the problem that if you type in something that does not correspond to an ivar name, such as george, you get this:
KVO1-5
The bottom field was never updated. And that is because this happened:
KVO1-6
What this is saying is that it failed to find an ivar called george, and so was unable to continue. It looked for accessors first, then gave up and tried to access the ivar directly and that failed too.

There is one change in KVO2. It adds a new method, one that is part of the Key Value Coding informal protocol:
KVO2-1
If the key used (entered in the top field) cannot be found, then instead of giving up, this method is called. It simply prefixes the key with "Unknown: " and returns it as the ivar value. lets see it in action:
KVO2-2
And now there is nothing in the run log.
The Bagelturf site welcomes Donations of any size