ghostrider
ghostrider

Reputation: 5259

unrecognized instance selector when opening segue

My app currently has the following layout :

Navigation Controller -> UIViewController -> UIViewController -> UIViewController

I can move between the controllers using segue.

The problem happens when I am trying to pass some data between the controllers.

This WORKS when going from the first view controller to the second one.

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

    [self performSegueWithIdentifier:@"OpenMatch" sender:nil];

}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"OpenMatch"]) {
        NSIndexPath *indexPath = [self.matchesListView indexPathForSelectedRow];
        SingleMatchViewController *destViewController = segue.destinationViewController;
        MatchData *match = [self.matchesArray objectAtIndex:indexPath.row];
        destViewController.matchId = match.objectId;
        destViewController.matchTitle = match.matchDescription;
    }
}

Now when going from second to third uiviewcontroller I have similar code:

- (IBAction)openStats:(id)sender {
    [self performSegueWithIdentifier:@"OpenStats" sender:nil];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"OpenStats"]) {
        MatchStatsViewController *destViewController = segue.destinationViewController;
        NSLog(@"Opening stats for match : %@",self.matchId);
        destViewController.matchId = self.matchId;
        destViewController.matchTitle = self.matchTitle;
    }
}

It gives me this error :

 -[UIViewController setMatchId:]: unrecognized selector sent to instance 0x9ba72a0

Properties in the destination controller are declared like this :

@property NSString*  matchId;
@property NSString*  matchTitle;

When the last 2 lines are commented out it passes. So the problem is with the destViewController.matchId

Can you help me on that?

Thanks.

Upvotes: 0

Views: 23

Answers (1)

rdelmar
rdelmar

Reputation: 104092

Notice that the error says [UIViewController setMatchId:], not [MatchStatsViewController setMatchId:]. You probably forgot to change the class of that third controller to your custom class in the storyboard.

Upvotes: 2

Related Questions