1

error occurs with below code---Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
                DetailViewController *dvc =[[DetailViewController alloc]initWithNibName:@"DetailViewController" bundle:nil];
                dvc.index = indexPath.row;
                [self.navigationController pushViewController:dvc  animated:YES];

              }
Losiowaty
  • 7,911
  • 2
  • 32
  • 47
Nishanth
  • 33
  • 8

1 Answers1

1

As mentioned in your comments you are using Storyboard, then this is not how you will initialize an object of UIViewController with the storyboard.

You must create object like this

DetailViewController *vcDetailViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"DetailViewController"];
vcDetailViewController.index = indexPath.row;
[self.navigationController pushViewController:vcDetailViewController  animated:YES];

Also, you need to give StoryBoard Id to your view controller, check image

enter image description here

Rajat
  • 10,977
  • 3
  • 38
  • 55