1

I'm having a problem similar to the one discussed in this thread, but the solution provided to him isn't working for me. I apologize for the lengthy description, but this is my first post on SO and I want to be complete.

I have a program that runs fine in the simulator. However, when I try to push it out to the device, I get an error that says this:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/....app> (loaded)' with name 'MainWindow''

So: it's trying to load a XIB called MainWindow, but it can't find it. That's because I don't have a XIB called MainWindow; the first XIB I load is called FrontPage.xib. I didn't start this program using one of the templates and thus was not provided with a MainWindow.xib file at the beginning.

The Google machine tells me that the Main nib file base name can be modified in my app's plist. So, I go there and I change it to FrontPage. Now, I get a different error:

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x12c270> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'

I'm pulling my hair out over here - anyone know a solution?

Community
  • 1
  • 1
Kyle
  • 13
  • 3
  • It looks like you have set a 'view' outlet set in the nib file via Interface Builder but its File's Owner doesn't have an instance variable/declared property named 'view'. –  Jan 28 '11 at 04:34
  • is FrontPage.xib a controller nib? – Seyther Jan 28 '11 at 04:35
  • Bavarious: Yes, in Interface Builder, my File's Owner does have an outlet to a view named "View". I'm not declaring this as a property anywhere in code - do I need to? This is where my inexperience to iOS programming is evident. :) – Kyle Jan 28 '11 at 05:03
  • Welcome to SO. SO policies are against salutations in posts, but otherwise, welcome. – Moshe Jan 28 '11 at 06:14

3 Answers3

2

Make sure that your view is connected to your "View" outlet in Interface Builder. You do this by right clicking on your "File's Owner" in IB and then dragging to the "View" outlet to your View. Here's an illustration from a game I'm working on. Notice the blue line, dragged from the dot on the right to the "view".

enter image description here

Another thing you will want to check is your Info.plist. Make sure that you have called your nib file FrontPage and not *FrontPage****.nib***.

Moshe
  • 57,511
  • 78
  • 272
  • 425
  • Hm. I can understand why this would solve the error I'm having - the confusing thing, though, is that the view and the File's Owner were already correctly connected via the process you displayed above. And my nib file, in the plist, does not have the suffix. The other strange thing is that I don't get this error until I try to load this as the main nib base - in the simulator, as long as I have the (nonexistent) MainWindow selected as my base nib, FrontPage.xib loads fine. Is there something special about the base nib that needs to be set somewhere? Is it a special file-type or something? – Kyle Jan 28 '11 at 15:25
  • I don't think so. One last place to check I'd in your delegate where you load the nib. Again, check that the proper name is set up there without the extension. – Moshe Jan 28 '11 at 17:11
1

If Frontpage.xib is going to be your application's main xib, then you have to create a Window object and an App Delegate object in that xib in order for the app to be able to load. Before you can start presenting view controllers and such you have to configure the app and the window or it will crash as you describe. I would suggest creating a new project using a Window based template and just take a look at the MainWindow.xib that gets created automatically and try to mimic it in your Frontpage.xib..

.. Although I would just sincerely suggest using a MainWindow.sib in your project and making your Frontpage.xib a normal view controller xib. If you choose to add a new file to your project, then choose User Interface, then choose Application xib instead of View xib, then it will set you up with something close to what you need.

The project templates are important and useful. You should always use them. I start all of mine with a Window Based template. It is the most basic template and the most flexible.

Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229
  • This did it. Thanks so much, Kenny - lesson learned about starting with the app templates. – Kyle Jan 29 '11 at 00:58
0

If the view controller for FrontPage.xib is set properly by setting the File owner property via IB then you also need to set the view property. you can do this by control dragging from Fileowner to the view. From the error it appears that you have yet not set the view property for your view. Open the nib in Interface builder and and look for the View Connection in connection Inspector , this must be connected to file owner's view outlet. You don't need to declare it as a property anywhere.

Moshe
  • 57,511
  • 78
  • 272
  • 425
Rahul Sharma
  • 3,013
  • 1
  • 20
  • 47