New iOS Developers Shouldn’t Use Interface Builder

Posted by by

When I first started learning Objective-C and the iOS SDK 2.x a few years ago, one thing that I constantly struggled to get my head around was Interface Builder. More specifically, why should I use it and how it could possibly benefit my iOS development – given that I could code a UI programmatically, and know exactly how it all worked? A colleague of mine even wrote a blog entry that mirrored my exact feelings towards Interface Builder back then.

Well over the past 6-12 months my attitude towards Interface Builder has changed. There are two reasons for this. Firstly, it’s now nicely integrated into XCode 4. Prior to that, who wanted to have 2 different apps running (XCode and Interface Builder) with popup windows spamming your desktop? That was a deal-breaker for me. Secondly, I’m now a more experienced developer. After using Interface Builder on a couple of projects, I am confident to say I am now more efficient as a developer when using Interface Builder. However, that wasn’t always the case, which leads me to my key message here:

If you’re new to iOS development, don’t touch Interface Builder until you are capable of building UIs programatically.

This isn’t the opinion of some crusty old dude proclaiming young whippersnappers must pay their dues. It’s the conclusion drawn by somebody who has always wanted to maximize their own productivity – both as a novice and a more experienced developer.

In the Beginning…

I think part of my initial frustration with Interface Builder was my lack of knowledge towards the iOS SDK when starting out. Sure, Interface Builder would let me drop a UITableView onto my view, but how the heck did I populate it with data? What the hell were all these blue lines I could drag around? Interface Builder was meant to be this awesome UI builder, but I had no idea how it worked.

Instead of learning Objective-C, iOS SDK and Interface Builder, new iOS developers should only focus on the first two. Interface Builder will make plenty of sense down the track.

This is probably why almost all of Apple’s sample code never contains Interface Builder files. For a new developer it’s just too much voodoo – just don’t have the knowledge of what you can do with Interface Builder.

It’s my opinion that new iOS developers should code their UI’s from scratch. Ignore Interface Builder; place it out of your mind; it should be dead to you for now. Focus on learning the SDK. For example, find out how a UITableView gets its data via a UITableViewDataSource , and how you can perform actions with a UITableViewDelegate .

Learn how to build UIs from the ground-up

I honestly feel that you learn so much more from coding all your UI’s from scratch when learning iOS development. You can easily see where your UITableViewDelegate is, because it’s there in your code; you assigned it textually, not via some magical blue line. You will learn more of the SDK in a shorter time, and you will really get exposure to what each component is capable of.

Furthermore, Apple’s sample code by will be easier to follow and you will not lose endless nights trying to figure out why, for example, you can’t select a table row – when it’s likely you just missed connecting the blue line in Interface Builder to a delegate.

It’s easier in code if, for example, you haven’t assigned a delegate (you won’t be able to see it because it won’t be there) – rather than trawling through IB property sheets to figure out what you haven’t hooked up correctly.

Interface Builder is awesome, once you understand what you can do with it

I am not an Interface Builder hater – if anything, I am a convert. For years I preached that Interface Builder was a waste of time; that I could do everything that Interface Builder allowed me to do – and more – if I programmatically create my UI.

But as I grew more experience, something changed. It was a case of ‘I was blind, but now I can see’.

I stopped seeing Interface Builder as this magical tool that was supposed to do anything I wanted. I began to see it as a tool that would help me setup my views quickly. It’s particularly handy for configuring auto-resizing. But it is only with experience that I can appreciate the benefits of using Interface Builder.

I now write less code and visually lay out my views and their associated delegates/references, all from within IB. I can do this confidently because if any problems arise – such as a delegate not being associated correctly – I have seen it many times before and know where in Interface Builder I need to look to see where I have gone wrong.

Interface builder will be a great tool for you to use – just give yourself time to learn the SDK first

Those new to iOS development wrongly assume that Interface Builder can do everything they think they want to do, yet they haven’t had enough exposure to the SDK.

You will get a lot more out of Interface Builder once your iOS SDK knowledge is at-least at an intermediate level. Until then, leave Interface Builder alone – it will only cause you heartache.