7

I have a class called TaskListViewController and I am going to ShowTaskViewController. In the beginning in ShowTaskViewController I didn't have a view object I only Had a TableView object where I was dynamically loading data from a database and it worked fine.

Now I deleted the TableView object in ShowTaskViewController class and I dragged and dropped a View object in the .xib file and also dragged and dropped a TableView object on top of it because I want to have some additional buttons in that class, but now its showing me this error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "ShowTaskViewController" nib but the view outlet was not set.'

Also this is the code I used to go to the ShowTaskViewController class before when it worked fine, now please help me to make the changes so the TableView object loads data properly.

-(IBAction)showAllTasks:(id)sender
{
    ShowTaskViewController *showTaskViewController = [[ShowTaskViewController alloc] initWithNibName:@"ShowTaskViewController" bundle:nil];

    [self presentModalViewController:showTaskViewController animated:YES];
}
Shahnawaz
  • 646
  • 1
  • 11
  • 25
  • please see this link http://stackoverflow.com/questions/4763519/loaded-nib-but-the-view-outlet-was-not-set-new-to-interfacebuilder – Sehrish Khan Jul 25 '12 at 07:27

2 Answers2

9

This is because in you xib your haven't set your view outlet.

Open you xib file select File Owner right click it and map your view outlet to your UIView in the xib.

For more detail plz check following links:

Loaded nib but the view outlet was not set - new to InterfaceBuilder

Error in Xcode "the view outlet was not set.'"

Hope this helps :)

Community
  • 1
  • 1
Kapil Choubisa
  • 5,152
  • 9
  • 65
  • 100
3

first declare outlet for your new tableView(Ctrl + Drag from xib to interface file) and later do something like this:

self.view=myTableView;
ilhnctn
  • 2,210
  • 3
  • 23
  • 41
  • 1
    I just tried doing that, but its still showing the same error. Am I doing anything else wrong? Please help! – Shahnawaz Jul 25 '12 at 08:02
  • @Shahnawaz It must work, if this is your first view controller, you have to check AppDelegate too, because you will need to rename the xib file mentioned there too – ilhnctn Jul 25 '12 at 08:19
  • btw, you have deleted the xib file and still trying to push it, rename your new added xib with ShowTaskViewController – ilhnctn Jul 25 '12 at 08:20
  • Oh no this is my fifth view controller class, 1st I made a class that is subclass of UITableViewController and then it only had the UITableView in the .xib file. Then I changed it to a subclass of UIViewController and implements interfaces: (I forgot the exact names but its of this region). – Shahnawaz Jul 25 '12 at 09:35