iPhone SDK tutorial: disconnecting your application from Interface Builder

This is a quick tutorial on disconnecting your iPhone project from Interface Builder using Xcode.

When you initially start a new iPhone project in Xcode, you get a project that loads from a NIB file.  This NIB file describes a template for how visual elements are layed out on the screen.

As a newbie to iPhone development I want to watch my project get created 100% through the code – I don’t want there to be any magic going on behind the scenes.  I’ll introduce the magic pieces one at a time, but for now: no Interface Builder. (There are a whole bunch of other things about Interface Builder that I actually don’t like, but that’s a different blog post)

To remove your dependence on Interface Builder from the application you need only to do these three things:

  1. In your Resources folder in Xcode, delete your .xib file named “MainWindow.xib”
  2. In your Resources folder in Xcode, open up the .plist file and remove the line that says “Main nib file base name” by selecting and clicking delete.
  3. In your main.m file you need to manually let the application know where to start your app and send important application events.  Change this line:

int retVal = UIApplicationMain(argc, argv, nil, nil); TO int retVal = UIApplicationMain(argc, argv, nil, @"[yourAppName]AppDelegate")
And presto – no dependency on InterfaceBuilder.

This entry was posted in apple, coding, devinsblog, iPhone and tagged , , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  •  
  •