views:

234

answers:

5

I'm fairly new to Cocoa. I was talking to my brother, who's put together a few iPhone apps, and I said something about Interface Builder. He said that he doesn't use it - he builds his UIs programmatically. He said that this way, he doesn't have to worry about loading the NIB. I understand that using Interface Builder actually creates instances of view/window/button/etc objects that are serialized and have to be deserialized when you load the application, but is the deserialization that expensive? Granted, he's talking about iPhone and I'm developing on a MacBook Pro, but still.

+8  A: 

I have yet to see an argument against using IB due to performance reasons, and having used both methods I havent seen any difference either way. For the more ui intense applications I usually end up not using IB only because it is difficult to build complex customized views with it. So really I tend to use IB for the more simple apps and go with the progammatic approach for the more complex apps. This approach obviously is performance optimizing as well.

ennuikiller
Even for complex applications, I'll use IB to layout the sub-bits of the UI in simple containing views and then plug 'em together in the larger UI programmatically.
bbum
+2  A: 

If both methods can be useful, I'd recommend going the Apple's way; i.e. using Interface Builder (IB). You'll get less code to write (and less code equals less bugs, less maintenance, less work ;) !), a better abstracted project, you'll be much more ready to inherit future goodies coming from Apple (remember Cocoa Bindings…), and soon you'll also be more productive.

Understanding what IB's doing for you (by going through your brother's method) is a very valuable knowledge too; so if you can do both on some li'l projects, do that. (As others said, for complex UIs, this will allow you to bypass it at times.) But still, in the end, I'd recommend using IB.

Frédéric BLANC
Oh, and just a quick note/correction: we're not talking about serialization here, but rather about archiving; as IB is also gonna save in your NIBs the IDs and relationships of your objects.
Frédéric BLANC
+5  A: 

Absolutely learn IB! It's worth it and will save you countless time over the long haul. Then use it when you can. When you cannot (high complexity) you always have the programatic approach but you'll find it FAR easier to maintain your nibs (IB) as your app grows and ages.

Meltemi
+2  A: 

Although Interface Builder is an old piece of software, with its roots in NeXTSTEP development, it is still (IMO) an elegant way of creating the visual aspects of software.
In this interview with Aaron Hillegass, he says that "Experienced Cocoa programmers put a lot of the smarts of their application in the NIB file. As a result, their project has a lot less code."
And as we all know: "Less source code is better"

weichsel
A: 

It depends a lot on the kind of application. ERP systems with a few hundred/thousand pages are not build with Interface Builder, as far as I'm aware.

Stephan Eggermont