Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Receiver (<ViewController>) has no segue with identifier 'addSegue'

I have a navigation controller that has a segue links between them called "addSegue". When I click on the tableView cell though the app crashes and I get the error below:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<MSAddFriendsViewController: 0x98cc340>) has no segue with identifier 'addSegue'

I don't think that I have any issues with my code. Here is the method in which I have the line showSegueWithIdentifier:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSMutableSet *selectedUsers = [NSMutableSet set];

[self.tableView deselectRowAtIndexPath:indexPath animated:NO];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];


cell.accessoryType = UITableViewCellAccessoryCheckmark;
PFRelation *friendsRelation = [self.currentUser relationforKey:@"friendsRelation"];
PFUser *user = [self.allUsers objectAtIndex:indexPath.row];
[friendsRelation addObject:user];
[self.currentUser saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
    if (error) {
        NSLog(@"Error %@ %@", error, [error userInfo]);

    }    }];

[self performSegueWithIdentifier:@"addSegue" sender:self];

}

Here is a picture of my storyboard

Here is an updated picture of my storyboard

like image 609
MicahKE Avatar asked Dec 21 '13 04:12

MicahKE


3 Answers

I had this same problem and actually my problem was that I was calling

WRONG: [self.navigationController performSegueWithIdentifier:@"ShowVerify" sender:self];

instead of

CORRECT: [self performSegueWithIdentifier:@"ShowVerify" sender:self];

so check that you are calling correct performSegueWithIdentifier method :)

like image 75
ooxio Avatar answered Oct 13 '22 01:10

ooxio


enter image description here

use segue identifier in Push Method and give the proper connection

if you are using Identifier, then call this line where u need

[self performSegueWithIdentifier:@"identifierName" sender:self];

Swift 2.X

self.performSegueWithIdentifier("identifierName", sender: self)

Swift 3

self.performSegue(withIdentifier: "identifierName", sender: self)

Regarding the new screen you have added that way. In that screen, when you're finished and want to remove it, it's just:

self.dismiss(animated: false, completion: nil)
like image 40
Anbu.Karthik Avatar answered Oct 12 '22 23:10

Anbu.Karthik


Hard to say for sure, but some other people have had similar problems:

  • In this question, the asker instantiated the storyboard with init instead of instantiateViewControllerWithIdentifier so the segue wasn't set up properly.

  • In this question, it was just something weird going on internally with xcode and the simulator, and running Product->Clean helped.

  • And of course, it's possible the segue name in the code doesn't match the segue name on the Storybord, but I'm guessing you've checked that a lot of times already!

like image 33
JKillian Avatar answered Oct 12 '22 23:10

JKillian