Lost in interface builder hell


#1

So I was trying to do the Silver Challenge for Chapter 5 and I got all messed up. My code Builds successfully but it throws exceptions because my XIB isn’t connected up right.
I know this because I deleted it after trying to fix things after I took out the segmented control. Apparently this isn’t a good idea. I could start all over I suppose… but what’s the trick to adding in a new XIB?

I can’t get any connections to work going from the File Owner over toward anything on the View. The other way for the delegate connections it works fine.

Any ideas?

Thanks,
-Dan


#2

There must be something I’m missing here… I brought back the whole project via Time Machine. Maybe this isn’t a good idea? I got it to work once by resetting the simulator, but now it won’t run.

2012-09-16 20:31:47.466 Whereami[6091:11603] *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘-[UIViewController _loadViewFromNibNamed:bundle:] loaded the “WhereamiViewController” nib but the view outlet was not set.’
*** First throw call stack:
(0x14a7022 0x1019cd6 0x144fa48 0x144f9b9 0x2432dd 0x243779 0x24399b 0x1a2401 0x1a2670 0x1a2836 0x1a972a 0x25f5 0x17a386 0x17b274 0x18a183 0x18ac38 0x17e634 0x16beef5 0x147b195 0x13dfff2 0x13de8da 0x13ddd84 0x13ddc9b 0x17ac65 0x17c626 0x232d 0x2295)
terminate called throwing an exception(lldb)

I checked some things mentioned on StackOverflow (like making sure the class is named on the xib file, and that the connections are still in place) but I still get this same error.

I’d appreciate any help… really I want to learn why this is so fragile.


#3

Xcode has already given you an important clue, shown in red above.

Therefore you should go and check in IB and make sure that the view outlet of WhereamiViewController is connected to the view object in WhereamiViewController’s NIB file. Can you see the view outlet in File’s Owner?


#4

My list of connections looks almost identical to page 107… the only difference is that I have “Text Field - Enter Location Name” (is that a book typo?)
When I hover over the filled in circles in the inspector area, the appropriate part of interface builder highlights. From that I interpret that they are correctly connected.

the debugger stops in main.m and the *argv (second line down in the debug list) points at the Simulator.
argv char ** 0xbffff4fc
*argv char * 0xbffff618 "/Users/dan/Library/Application Support/iPhone Simulator/5.1/Applications/91243910-9E86-…big long number
**argv char ‘/’

Is this big long application number tied to a certain set of files inside a bundle? Bringing them back from TM breaks this?


#5

Have you actually checked the view outlet first?

If your view outlet is connected, wipe the slate clean (go and delete that directory: …/Applications/91243910-9E86-…) and compile again.


#6

Well as far as I can tell it’s connected. I "x"d it out and reconnected it via dragging from the File’s Owner box icon down to the View icon in the Objects section right below it. Everything highlights the same which I think means it’s connected.

I deleted the app down in that directory … this is interesting to see where it puts this! And I’m really getting used to slinging the Xcode windows around.

But alas… the error is the same. This is definitely a simulator issue because it doesn’t throw the error until the simulator is fully launched. I also reset the simulator and I tried running with it launched or not. It does the same thing. Is there some sort of binary connection between the XIB file and the rest of the project? Oh… these files are also inside a dropbox folder - would that have any affect? Pretty soon I’ll just hit the next chapter - it would be good to learn why this doesn’t work though.

Thanks for writing back!


#7

Now, it’s getting really hard to tell from a distance.

I were you, I would start with a new, clean slate: start from scratch and create a new project, but don’t drag your old source files onto the new project; add them carefully by using the Add Files to menu item if you don’t want to type them in from scratch.


#8

Creating a fresh project and adding the files in worked… but it’s not the whole story. If I create a new project and give it the same project name “Whereami” I always get this same crash in main.m. But if I create a new project name and then add all the files back in it works great. I found that I could even add the XIB file back with all the connections intact. One guess is that the field called “Bundle identifier” on the Summary screen, needs to be unique. If you create a duplicate project - even if you delete the older one, I think you run into problems. Does the book cover this later on?

Dropbox seems to have no effect - I did see where the sync indicator was still spinning as I’m attempting to build and run so maybe that could get me into trouble later. But I created a new project with a unique name, added all the files and it ran just great.

-Dan