The Muggle Coder

It’s no secret that I’m not a fan of frameworks. As I mention in a recent .Net interview:

I don’t like magic. I like knowing how something works.

I don’t like taking things for granted because if magic breaks, unless it’s your own trick, you don’t know how to fix it.

And nothing in recent experience is as magical as the iPhone SDK. I’m sure the Objective-C language and Apple’s dependent frameworks solve a lot of problems encountered by experienced software developers. As an inexperienced developer without the context of those problems, these clever pre-made solutions seem like unnecessary hoops erected for the sole purpose of jumping.

Compounding this confusion are NIBs, XIBs, and Interface Builder. Interface Builder allows you to create and connect visual interface elements to your Objective-C classes. These interfaces are stored precompiled in a NIB or as XML in a XIB. It sounds like a brilliant idea—and it is—but as a software solution it’s a confounding mess. Especially when you’re developing software that doesn’t require standard UI elements (like an 8-bit game).

So the first thing I do when creating a new iPhone project in Xcode is sever any connection with Interface Builder or dependence on XIBs. I prefer to start with a Window-based Application and immediately Delete (Also Move to Trash) Resources/MainWindow.xib. Then in Resources/<AppName>-Info.plist I delete the “Main nib file base name” row and save. Finally I copy the AppDelegate class name from Classes/<AppName>AppDelegate.h (deleting the no-longer-necessary IBOutlet from the @property declaration while I’m in there) and paste it in as the NSString fourth argument of UIApplicationMain in Other Sources/main.m like so:

UIApplicationMain(argc, argv, nil, @"<AppName>AppDelegate");

I can then create my window programmatically in the applicationDidFinishLaunching method with:

windowFrame = [[UIScreen mainScreen] bounds];
window = [[UIWindow alloc] initWithFrame: windowFrame];

With no IBRabbits in my HatDelegate or Trick Referencing Outlets up my SleeveController I can go about the business of making my own mistakes and learning from them; so that one day all of this might make sense.

NaNoDrawMo Animals
An MML Bundle for Textmate
Shaun Inman
December 4th, 2009 at 8:46 am