views:

930

answers:

5

Hi,

I have been programming with the iPhone SDK for some time now.

I have not been using Interface Builder. This scares me a little. I know that in effect I may be 'fighting the framework' but I do not see it that way.

I find it very easy to just instantiate my UITabBarController in my app delegate, instantiate a UINavigationController, then push and pop view controllers as I go.

Naturally I do not have an extensive knowledge of how to architect an app with XIB files because I have never done so, however I do know the general gist of it, having built some Mac apps in Cocoa using NIBs. So I am not completely ignorant.

My question is whether there is an increase in development time when choosing to lay out UITableViewControllers and UIViewControllers using XIBs rather than programmatically instantiating them and then setting up the ivars.

As I see it, both methods still require you to subclass the view controller for customization which will probably occur for the majority of your views. As well, there are still manual classes required for delegates, and the process of connecting outlets from within the XIB seems comparable to me from setting an ivar.

Or am I missing some other major point?

Thanks!

+1  A: 

Don't worry too much, IMO Interface Builder is a little over-rated too.

It's definitely useful for getting things up and running quickly, or if you have an app with a lot of screens that are tedious to setup, but you're not missing much.

Andrew Grant
+1 to counter a drive-by downvote. I don't agree, but you're entitled to state your opinion.
Abizern
+2  A: 

Code takes much longer to write to configure UIs than IB does.

Plus, you can hand off design to designers and let them tweak the UI.

Genericrich
Just exactly how much tweaking can a designer actually do with a XIB file? I don't think there is a whole lot aside from adjusting the set options, and resizing the views. These are things which don't even take up a huge amount of time when designing for the iPhone.
You would be surprised. I've seen pretty dramatic turnaround on some XIB files in the hands of a good designer, once they learn the tool.Plus, you don't have to do it. The best code is the code you don't have to write!
Genericrich
+2  A: 

In the end they both accomplish the same thing. You should use either one depending on the circumstances. Most of the time writing the code to create and position views, and especially maintaining it down the road, will take much longer than using IB. In a simple app for the iPhone though, this might not be true and you'd be just as well off creating everything in code. Basically, you should know how to do both, and pick the path that involves the clearest code and quickest development.

Marc Charbonneau
+2  A: 

IB shines when you're using it to actually lay out views; even two or three views can be a real hassle to lay out and configure in code. I do tend to use it for tab bar and navigation controllers, and sometimes for subcontrollers (usually only if I think the user is very likely to use it), but that's more just because I'm already there so I find it convenient.

With this new version 3 OS they're announcing next week, I'm hoping Interface Builder gains some of the flexibility it has in Cocoa, where you can add palettes for your own classes and even build up complex non-view data structures (by using custom palettes). We'll have to see, though.

Brent Royal-Gordon
In layoutSubviews(), you change the CGRect valuesa in code. In IB, you change the same values using a form input box. For tab bar and navigation controllers, when adding buttons - all you do is set the left/right BarButtonItem ivar. In IB you can view the Info pane and change buttons there.
Just saying that yes, both achieve the same thing. But the real question I'm getting at is, is there a development time improvement using one over the other. The examples I just gave seem to take the same amount of time to accomplish.
I forgot one thing. In IB you can drag views around and arrange them and see how they look, and then adjust their coordinates later to refine it. Programatically you can accomplish the same thing by building the app, viewing it and then changing the rect values accordingly. Again, both seem similar.
I started writing iPhone apps with Beta 2 of the SDK. My first app still does not use any nib files. So I know that I can do everything and more in code that I can do in Interface Builder. I also know that doing so is a tremendous hassle.
Brent Royal-Gordon
A: 

For the uses you outline just doing things in code is fine, and possibly even a little easier to understand.

Laying out views, or custom cells though... then you get into a ton of font/color/position setting that quickly explodes into a lot of code, hard to maintain and tweak. Much easier to adjust what you want in IB in those cases.

Kendall Helmstetter Gelner