11

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

Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143
MicahKE
  • 125
  • 1
  • 1
  • 7

4 Answers4

16

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 :)

ooxio
  • 806
  • 1
  • 10
  • 13
11

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)
Fattie
  • 27,874
  • 70
  • 431
  • 719
Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143
  • How to pass the value to next view controller with this method? – Aniruddha Aug 08 '14 at 05:00
  • @Aniruddha -- yesterday I already answered for your question,if u don't mine I solved ur issue, can u send your project in mail id karthik.saral@gmail.com – Anbu.Karthik Aug 08 '14 at 05:14
  • I'm using Storyboard. I have 2 classes A and B. From A, I want to pass the value to B. This is how I done it but it is not working. `B *bb = [[B alloc]init]; b.strName = @"Abcd"; [self performSegueWithIdentifier:@"segueName" sender:nil];`. Please don't mind I cannot send you the project. – Aniruddha Aug 08 '14 at 05:16
  • @Aniruddha - its K man, use this link http://stackoverflow.com/questions/19739037/pass-data-to-view-controller-using-storyboard-segue-ios otherwise say ur mail id i send the sample code in different methods, k – Anbu.Karthik Aug 08 '14 at 05:20
6

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!

Community
  • 1
  • 1
JKillian
  • 18,061
  • 8
  • 41
  • 74
0

Check whether UIKIT being or not in header file. I unknowingly made new VC a subclass of View Controller.