Interface Builder

Xcode 4: Finding User Interface Elements

One of Xcode 4′s biggest changes is its integration with Interface Builder. There is no longer a separate Interface Builder application. Select a xib file from the project navigator to create your application’s user interface. You may be wondering where the user interface elements are located in Xcode 4.

They are in the object library. Choose View > Utilities > Object Library to open the object library, which is located in the lower right corner of the project window.

Xcode 4 Object Library

 

Comments (6) | Trackback

Interface Builder 3.2: Outlets and Actions

In previous versions of Interface Builder, you used the identity inspector to add outlets and actions to a user interface element. Interface Builder 3.2 moved this functionality to the Library. If the Library window isn’t open, choose Tools > Library to open it. Click the Classes tab in the Library window. Select a class. Use the Outlets and Actions tabs to view, add, and remove outlets and actions for the selected class.

InterfaceBuilderActions

No comments | Trackback

Interface Builder 3 Change: No Subclass Creation

Older versions of Interface Builder let you create subclasses for Cocoa applications and generate source code files for the subclasses you created. As an example, you could drag an OpenGL view to a window, subclass the OpenGL view, and have Interface Builder create .h and .m files for the subclass. But Interface Builder 3 no longer lets you create subclasses. How do you create the subclasses?

You create the subclasses the old-fashioned way: with source code. Create your subclasses in Xcode. Interface Builder and Xcode are synchronized so the subclasses you create in Xcode appear in Interface Builder as well.
 
Choose File > New File to create a new file. A window will open containing many file types for you to choose from. For a Cocoa program you would want one of the Cocoa files unless you’re writing a Cocoa program in Ruby, in which case you would use one of the Ruby files. Name your file and click the Finish button. You’ve created a subclass file.

Instantiating Your Class
After creating your class in Xcode, you may need to add an instance of your class to the nib file so you can make connections in Interface Builder. If Interface Builder’s library window is not open, open it by choosing Tools > Library. The library window contains Interface Builder’s user interface elements.
Select an NSObject from the library window. NSObject is a blue cube. Drag NSObject to the nib file window. An NSObject named Object should now appear in the nib file window. Choose Tools >Identity Inspector to open the identity inspector. Select the NSObject in the nib file window.
The top of identity inspector should have a combo box labeled Class. Choose your class from the list of classes in the combo box. The name of the NSObject instance in the nib file window will change from Object to the name of your class. Any outlets and actions in your class should appear in the identity inspector.
If your classes are not appearing in Interface Builder, choose File > Synchronize With Xcode in Interface Builder.
Comments (7) | Trackback
Powered by WordPress