无法识别的选择器发送到setDetailModal的实例

时间:2014-06-23 22:53:03

标签: ios objective-c segue

尝试点击我的应用中的segueway时,我收到以下调试消息。

"SmokingPig[13840:c07] -[UIViewController setDetailModal:]: unrecognized selector sent to instance 0x75836c0"

这是我的TableViewController.m文件(或者我认为至少搞砸的部分)

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"ShowDetails"]) {
    DetailViewController *detailviewcontroller = [segue destinationViewController];

    NSIndexPath *myIndexPath = [self.tableView indexPathForSelectedRow];

    int row = [myIndexPath row];
    detailviewcontroller.DetailModal = @[_Title[row], _Description[row]];
}

这是我的DetailViewController.h文件     #import

@interface DetailViewController : UIViewController

@property (strong, nonatomic) IBOutlet UILabel *TitleLabel;
@property (strong, nonatomic) IBOutlet UILabel *DescriptionLabel;

@property (strong, nonatomic) NSArray *DetailModal;

@end

1 个答案:

答案 0 :(得分:2)

segue指向通用UIViewController的实例,而不是您的DetailViewController。如果在IB中描述了segue,请选择segue目标端的视图控制器,然后使用身份检查器(左起第三个检查器)并确保将自定义类设置为DetailViewController。

你可能也会收到警告:

DetailViewController *detailviewcontroller = [segue destinationViewController];

使用强制转换修正:

DetailViewController *detailviewcontroller = (DetailViewController *)[segue destinationViewController];