tags:

views:

542

answers:

5

I'm going through the Beginning Iphone Development Apress book and I'm constantly getting problems when building my NIB files. My practice apps crash because of the NIBS. I now this because I'll just trade out mine for the sample ones and the app will work. I'll look at the sample nib and all of my connections will be the same. I'm having problems debugging my NIBS and figuring out exactly what's wrong. So...

1) Can you just design your interface in IB and do all the wiring in Code?

2) What's the best way to figure out what's wrong with your NIB's?

3) Anybody else have the same problems with doing the examples in the Apress book?

+3  A: 

1) Can you just design your interface in IB and do all the wiring in Code?

You can but it's WAAAY more work. If you don't want to use IB, then doing everything in code is a better options.

2) What's the best way to figure out what's wrong with your NIB's?

Check each control and check all reference outlets (Command-2) and class dentities (Command-4).

Check Interface, Implementations for IBActions and IBOutlets, and Implementations for proper load sequences. (i.e. if using IB then initialize your view in viewDidLoad)

3) Anybody else have the same problems with doing the examples in the Apress book?

No

Jordan
+2  A: 

Interface Builder will indicate errors and warnings in NIB files by showing an alert icon in the bottom-right corner of the NIB document window. Click on that to see what the warnings are.

You can safely ignore "illegal geometry" warnings but missing outlets etc can be fatal.

Daniel Dickison
+1  A: 

If your apps "crash because of the NIBS", then what kind of error message are you getting when the crash occurs? Usually there's a pretty big clue about what's wrong if you look in the Xcode console, and usually that's the best way to start finding out what's causing the crash.

Tom Harrington
+1  A: 

You can build your UI totally in code if you want. I personally prefer this and only resort to NIB files for views that have a lot of items that need to be positioned.

I recommend Erica Sadun's The iPhone Developer's Cookbook for a good tutorial that shows you how to do this. I wrote a review of it here.

NIBs clearly have their place, and many developers prefer to wire things up using a visual tool like Interface Builder. But some of us (like me) would rather do things in code where practicable.

Don McCaughey
A: 

I am pretty much a newbie as you as well, but found this post which advises on striking a balance between the two and illustrates it with an example:

http://wiresareobsolete.com/wordpress/2010/03/striking-the-balance-interface-builder-vs-code/

Sara