View controller app crash

I'm trying to create an app kinda like a dictionary and i have the table view with cells working but when i click on a word to go to the detail veiw controller the app crashes and gives me a "Thread 1: signal SIGABRT" error. I'm using a plist to put my data in. I think the problem is in here somewhere in this method.


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    NSString *theInfo = [info objectAtIndex:indexPath.row];
    if(!self.detailViewController){
        self.detailViewController=[[DetailViewController alloc]
                                   initWithNibName:@"DetailViewController" bundle:nil];
    }

    self.detailViewController.detailItem = theInfo;
    [self.navigationController pushViewController:self.detailViewController animated:YES];

}

MasterViewController.m


#import "MasterViewController.h"
#import "DetailViewController.h"
@interface MasterViewController ()
@property NSMutableArray *objects;
@end
@implementation MasterViewController
@synthesize detailViewController= _detailViewController;
@synthesize name,info;
- (void)awakeFromNib {
    [super awakeFromNib];
}
- (void)viewDidLoad {
    self.navigationItem.title=@"Rocks";
    NSString *dataFile = [[NSBundle mainBundle ] pathForResource:@"Data" ofType:@"plist"];
    _Rocks = [[NSDictionary alloc] initWithContentsOfFile:dataFile];

    name = [_Rocks objectForKey:@"Name"];
    info = [_Rocks objectForKey:@"Info"];

    [super viewDidLoad];
    /
    self.navigationItem.leftBarButtonItem = self.editButtonItem;
    UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)];
    self.navigationItem.rightBarButtonItem = addButton;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    /
}
- (void)insertNewObject:(id)sender {
    if (!self.objects) {
        self.objects = [[NSMutableArray alloc] init];
    }
    [self.objects insertObject:[NSDate date] atIndex:0];
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
    [self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
#pragma mark - Segues
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([[segue identifier] isEqualToString:@"showDetail"]) {
        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        NSDate *object = self.objects[indexPath.row];
        [[segue destinationViewController] setDetailItem:object];
    }
}
#pragma mark - Table View
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    /
    return[name count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
    /
    /

    NSString *nameOfRock = [name objectAtIndex:indexPath.row];
    cell.textLabel.text = nameOfRock;


    return cell;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    /
    return YES;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {


    if (editingStyle == UITableViewCellEditingStyleDelete) {
        [self.objects removeObjectAtIndex:indexPath.row];
       [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
         /
    }
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    NSString *theInfo = [info objectAtIndex:indexPath.row];
    if(!self.detailViewController){
        self.detailViewController=[[DetailViewController alloc]
                                   initWithNibName:@"DetailViewController" bundle:nil];
    }


    self.detailViewController.detailItem = theInfo;
    [self.navigationController pushViewController:self.detailViewController animated:YES];

}
@end


MasterViewController.h


#import <UIKit/UIKit.h>
@class DetailViewController;
@interface MasterViewController : UITableViewController
@property (nonatomic, strong) NSDictionary *Rocks;
@property (nonatomic ,strong) NSArray *name;
@property (nonatomic, strong) NSArray *info;
@property (strong, nonatomic) DetailViewController *detailViewController;
@end


DetailViewController.h


#import <UIKit/UIKit.h>
@interface DetailViewController : UIViewController
@property (strong, nonatomic) id detailItem;
@property (weak, nonatomic) IBOutlet UILabel *detailDescriptionLabel;
@end



DetailViewController.m

#import "DetailViewController.h"
@interface DetailViewController ()
- (void)configureView;
@end
@implementation DetailViewController
@synthesize detailItem=_detailItem;
@synthesize detailDescriptionLabel= _detailDescriptionLabel;
#pragma mark - Managing the detail item
- (void)setDetailItem:(id)newDetailItem {
    if (_detailItem != newDetailItem) {
        _detailItem = newDetailItem;
           
        /
        [self configureView];
    }
}
- (void)configureView {
    /
    if (self.detailItem) {
        self.detailDescriptionLabel.text = [self.detailItem description];
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
    /
    [self configureView];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    /
}
@end

Set an exception breakpoint so execution stops where the error is thrown. Then you don't have to guess where the error is.


What is the error message printed in the console?

This is the error message being printed out "Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/MattNortz/Library/Developer/CoreSimulator/Devices/D5EE4805-0CEE-4515-8446-F205A2DB9F40/data/Containers/Bundle/Application/36950C54-3E44-4EE9-B0B8-EEC39068F017/tests.app> (loaded)' with name 'DetailViewController''"

And is there a XIB with the name "DetailViewController.xib" in your bundle?

How do i name it DetailViewController.xib when all my view controllers are in the main.Storyboard?

If all your VCs are in the storyboard then you should be calling UIStoryboard's instantiateViewControllerWithIdentifier: method, not alloc initWithNibName.


self.detailViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"foo"];


Instead of @"foo" you would pass whatever identifier you gave the VC in the storyboard.

View controller app crash
 
 
Q