Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewController unrecognized selector sent to instance

I have a tableviewcontroller and a detailtableviewcontroller when I pass an integer I get

-[UITableViewController setSurveyNumber:]: unrecognized selector sent to instance

Bizard thing is exact same code works for tableviewcontroller to -> uiviewcontroller

table -> table code

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([segue.identifier isEqualToString:@"pushSurveyDetails"])
    {
        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        NSInteger row = [indexPath row];

        SurveyDetailViewController *surveyController = [segue destinationViewController];
        surveyController.surveyNumber=row;

    }
}

in SurveyDetailViewController.h

@interface SurveyDetailViewController : UITableViewController
{

}

@property int surveyNumber;

@end

SurveyDetailViewController.m

@implementation SurveyDetailViewController
@synthesize surveyNumber;
- (void)viewDidLoad
{
    [super viewDidLoad];
    NSLog(@"Survey Number is %i",surveyNumber);
}

why this error occurs?

like image 587
Mord Fustang Avatar asked Jan 10 '13 17:01

Mord Fustang


1 Answers

The error message indicates that [segue destinationViewController] returns a UITableViewController and not a SurveyDetailViewController as expected.

The controller class can be set in the storyboard file.

like image 125
Martin R Avatar answered Nov 15 '22 02:11

Martin R