Database Reference
In-Depth Information
Adding Objects to the xib
The first part of the user interface we will work on is the objects in the xib
file. As with most applications, we need to add the AppDelegate to the xib so it
will be both instantiated on start-up and properly linked into the application
itself.
Add the AppDelegate
Depending on the whims of the templates within Xcode, the AppDelegate may
already be in the xib file upon opening MainMenu.xib . If it is, great! Move on to
the next section. If it's not, we need to add it. In addition, please note that
depending on the version of Xcode that is running, the application delegate
could have the application name prepended to it. If it does, we must substitute
that name for any reference to AppDelegate in this context.
To add the AppDelegate to the xib file, follow these steps:
1.
Find the NSObject in the Library palette, and drag it to the xib's window.
2.
Click the name of the NSObject . When it is editable, change it to AppDelegate .
3.
Go to the Identity tab on the Inspector palette, and change the class of
the object from NSObject to AppDelegate .
4.
Right-drag from the application to the AppDelegate object, and select
Delegate.
When these steps are complete, the AppDelegate class will be instantiated when
our application launches, and the application will send all delegate messages
to it.
Adding the NSArrayController Objects
We want our application to display a list of all the recipes in a single window.
To accomplish this, we need to be able to reference the data so it can be dis-
played. So, let's add three NSArrayController objects into our xib that reference
that data. Our window then references those NSArrayController objects. Once the
NSArrayController objects are added and configured, the xib looks like Figure 20,
The main menu xib , on page 125 .
To add an NSArrayController for the recipe entities, follow these steps:
1.
Find the NSArrayController object in the library, and drag it to the xib file.
2.
Click the name of the NSArrayController . When it is editable, rename it to
Recipes . If you have trouble getting the element into edit mode, change the
 
 
Search WWH ::




Custom Search