
I am using Interface Builder version 3.1.2 (see image above). This kind of jives with the version of XCode I am using. See below.
Note: when developers talk about the Interface Document Window they are really describing the .xib file (or the window presenting the .xib) file. Recall, the .xib file contains the interface design document that archives the elements of your user interface. Once saved the .xib file contains the archived version of your user interface as well as any state specified at design time.
Controller objects in the context of interface building is an arbitrarily named object that has been added to the user interface document. This object has outlets (instance variables) as well as actions (what it does).
You define the object's outlets and actions using the Identity Inspector (cmd-4).

So we've created:
- some basic user interface with some user interface components (e.g. 2 buttons and 2 labels)
- a controller object (to be used to control how the user interface is used.
Now we want to connect the UI components to the controller. Welcome the Connections Inspector (cmd-2)
BTW, you may have observed a pattern here with regard to how you can activate the various inspectors:
- cmd-1: Attributes Inspector
- cmd-2: Connections Inspector
- cmd-3: Size Inspector
- cmd-4: Identity Inspector
Controller classes are defined within the Interface Builder. Now we need to connect it to the application...by creating/generating an actual source file. NOTE: if we simply try to run the application after creating an object within the Interface Builder there will be an error as when the NIB is unarchived it will try to instantiate a Controller class...but we have not yet generated the source for it and compiled the source.
You'll get an error like the following:
2009-07-10 16:40:15.586 HelloPoly[4322:20b] Unknown class Controller in Interface Builder file.
Don't despair! In Interface Builder select the Controller object and then do a File -> write class files.
Be sure to look at UIKit Reference API
One thing to remember is that everything you can do in Interface Builder you can do programmatically.

No comments:
Post a Comment