Real Men Don’t Use Interface Builder

When I start to learn a new development platform I prefer, at least in the beginning, not to develop behind a RAD tool like InterfaceBuilder. I like to understand how things work before I look to a tool to do the work for me. Doing things “by hand” (at least initially) often gives me a better understanding of the tools and helps me to deal with issues as they inevitably come up.

Here is a simple set of steps you can take to prepare a new project that doesn’t “hide” anything behind InterfaceBuilder.

Step 1. Remove the value in “info.plist” called “Main nib file base name”
Step 2. In the main.m file, change the line

int retVal = UIApplicationMain(argc, argv, nil, nil);

to …

int retVal = UIApplicationMain(argc, argv, nil, @"MyAppDelegate");

Where @"MyAppDelegate" is the name of your application delegate class.

Step 3. In the App Delegate class create a window and setup your view:

- (void)applicationDidFinishLaunching:(UIApplication *)application {
     // create and initialize the window (normally IB does this for you) 
     window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
     // Start to create the initial controller and view (this is typically where your code starts)
     navigationController = [[RootViewController alloc] init];
     // Configure and show the window (e.g. add you view to the window
     [window addSubview:[navigationController view]];
     // Now show the window
     [window makeKeyAndVisible];

Step 4. (Optional) Remove the IBOutlet from the @property lines in the Application Delegate file because these are only ever used by the InterfaceBuilder.

Step 5. (Optional) Go ahead and delete any of the *.xib files that may have been created by the new project wizard.

  1. Hi, this is a great post, I have a question, if you build from scratch rather than using Interface Builder, will you still be notified for events like memory low warning, and something viewDidLoad?


    • Yes, you’ll still get all of the same events regardless of the approach.

  2. It’s great to understand how to write code that does what Interface Builder does for you. But don’t fall into the trap of thinking that’s a better approach. Serious iOS and Mac developers use Interface Builder when appropriate, and it’s a big red flag to us when somebody says they avoid it.

Comments are closed.