Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the GameView nib but the view outlet was not set

This is not the same situation as the multitude of other similar questions here.

* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the GameView nib but the view outlet was not set.'

You might be thinking "do as it says, connect the File's Owner to the View in IB!". But the thing is, I don't even HAVE a GameView.xib in my project or even in the project directory.

I do have a "GameViewController.m" and matching "GameViewController.xib" in my project. Using that GameViewController is what brings up this error, but I don't understand where it gets the idea to try and load "GameView.xib". Shouldn't it use "GameViewController.xib" instead?


If I grep my project directory, I do see it referenced from "UserInterfaceState.xcuserstate".

<string>file://localhost/Users/bemmu/Dropbox/b2/iphone/ValleyStory/ValleyStory/GameView.xib</string>

This mentioned file does not exist. I might have had a file with that name before and renamed/deleted it, but it's not being referenced to from anywhere that I can see in IB.

Did I manage to confuse xcode?

like image 446
Bemmu Avatar asked Mar 28 '11 19:03

Bemmu


5 Answers

In my case this error was produced by dumb mistake - I delete _view view dumb mistake

like image 88
WINSergey Avatar answered Oct 03 '22 17:10

WINSergey


My solution was a little different.

  1. Click on the xib in interface builder
  2. Select File's Owner on the left
  3. Open the File's Owner's connections inspector
  4. If the view property isn't yet wired, control-drag it to the view icon (under the file's owner and first responder icons).
like image 28
bbrame Avatar answered Nov 20 '22 06:11

bbrame


Check any nib files you're using (like MainWindow.xib). If you are loading GameViewController from a nib, check the file it's loading from (under the info tab in the inspector). Make sure it's set to "GameViewController" and not "GameView".

like image 5
Cameron Spickert Avatar answered Nov 20 '22 06:11

Cameron Spickert


I had this issue as well, but had to solve it a different way. Basically, I have a view controller name MainViewController, which has a xib named MainViewController.xib. This nib has it's view property set to the File Owner which was MainViewController.

I also made a MainView.xib that contained a view that was going to be programmatically added to the view defined in MainViewController.xib and it's view. It basically encapsulated an internal view that would be in the MainViewController.xib's view, and also had it's File Owner set to MainViewController.

So basically, I wanted MainViewController.xib to load as the nib for the MainViewController object, and inside MainViewController, at some later point, I would add the internal view specified by MainView.xib.

A couple issues arose:

1.) I found in the Apple docs that when loading a view controller via storyboard or nib:

"If the view controller class name ends with the word “Controller”, as in MyViewController, it looks for a nib file whose name matches the class name without the word “Controller”, as in MyView.nib.

It looks for a nib file whose name matches the name of the view controller class. For example, if the class name is MyViewController, it looks for a MyViewController.nib file."

Therefore, you cannot have a nib called MainView.xib if you also have a nib called MainViewController and want MainViewController.xib to be the primary nib for MainViewController.

2.) Even if you delete MainView.xib or rename it to something else (MainInternalView.xib in this case), you MUST delete / clean your iOS simulator as the old nib file (MainView.xib) will still remain in the application. It doesn't overwrite the whole application package when you rebuild / rerun your application.

If you don't want to reset your content settings (perhaps you have some data you want to preserve), then right-click on your application in your iOS Simulator folder, Show Package Contents, find MainView.nib, and delete it. Xcode will NOT do this automatically for you when you rebuild, so we need to manually remove the old nib.

Overall, don't make nibs named MainViewController and MainView, i.e. nibs with the same prefix. Call MainView.xib something else, like MainInternalView.xib.

like image 5
rvijay007 Avatar answered Nov 20 '22 08:11

rvijay007


I recently solved this issue. Make sure you back up your project before following the steps given here (just in case). These steps solved my issue

  1. Quit Xcode
  2. Navigate to UserInterfaceState.xcuserstate located at .xcodeproj/project.xcworkspace/xcuserdata/<username>.xcuserdata and delete the file.
  3. Reopen Xcode. Xcode will create a new UserInterfaceState.xcuserstate which will be clean.
like image 2
unspokenblabber Avatar answered Nov 20 '22 07:11

unspokenblabber