Search code examples
iphoneuitableviewios6storyboard

Storyboard doesn't contain a view controller with identifier 'bSegue''


In the storyboard from the UITableView added one segue named bSegue and bSegue Identifier class name is abcViewController.

In the code writing it as

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController *viewController;
switch (indexPath.row) {
    case PDF: 

        viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"bSegue"];
        break;
            default: 
        viewController = [[UIViewController alloc] init];
} 
[self.navigationController pushViewController:viewController animated:YES];
}

but when tried to run app it shows error NSInvalidArgumentException', reason: 'Storyboard () doesn't contain a view controller with identifier 'bSegue'

I double checked it segue identifier is correct then why it is giving this error.

Any ideas.

Thanks


Solution

  • You are confusing view controller identifiers with segue identifiers.

    Your line [self.storyboard instantiateViewControllerWithIdentifier:@"bSegue"] is looking in the storyboard for a view controller with a Storyboard ID of bSegue.

    What you want to do is call the segue identifier you have created with performSegueWithIdentifier:sender:

    so it would look like [self performSegueWithIdentifier:@"bSegue" sender:nil];