Key Value Coding 7: Accessing a Dictionary
2006-09-04
Download the code for KVO7. This program is a side step that uses a key path to return a dictionary:

When you enter the ivar name at the top it displays information in one pair of fields or the other depending on whether the vehicle is a car or a bike.
All the changes in this code are in the AppController. It accesses the ivars like this:

Look at the variable d. It is set with a key path that looks like cars.limo. So that returns a dictionary and the rest of the code accesses that dictionary with valueForkey. nil values are returned if the vehicle named is not in the dictionary, so the code uses that to fill in the correct fields of the window.

When you enter the ivar name at the top it displays information in one pair of fields or the other depending on whether the vehicle is a car or a bike.
All the changes in this code are in the AppController. It accesses the ivars like this:

Look at the variable d. It is set with a key path that looks like cars.limo. So that returns a dictionary and the rest of the code accesses that dictionary with valueForkey. nil values are returned if the vehicle named is not in the dictionary, so the code uses that to fill in the correct fields of the window.
The Bagelturf site welcomes Donations of any size