Key Value Coding 3: Adding A Custom Class
2006-08-17
Download and open up KVO3. KVO3 (again the project is called KVO1) starts a new application, this time with an AppController object and a Car object. Here is what its window looks like:

You enter the name of the ivar you want to see and its values are shown below when you press Show. The Car class looks like this:

and its implementation is:

It simply sets up default values for each object instance when initialized and handles thee undefined key as before. There are no accessors here. If I try an ivar that does not exist, I get the Unknown message again:

In AppController, I have two Cars defined, suv and convertible.:

and the code that accesses these is:

The message valueForKey is simply sent to each of the Car objects to get the values for the fields. And I didn't write any accessor code for the Car class.

You enter the name of the ivar you want to see and its values are shown below when you press Show. The Car class looks like this:

and its implementation is:

It simply sets up default values for each object instance when initialized and handles thee undefined key as before. There are no accessors here. If I try an ivar that does not exist, I get the Unknown message again:

In AppController, I have two Cars defined, suv and convertible.:

and the code that accesses these is:

The message valueForKey is simply sent to each of the Car objects to get the values for the fields. And I didn't write any accessor code for the Car class.
The Bagelturf site welcomes Donations of any size