【问题标题】:[UIViewController setRecipeName:]: unrecognized selector sent to instance[UIViewController setRecipeName:]:无法识别的选择器发送到实例
【发布时间】:2013-06-27 07:18:09
【问题描述】:

我是(来自java);目标 c 和 xcode 的新手。下面是构建良好但抛出unrecognized selector sent to instance 的代码。我试图通过谷歌搜索来修复它。但没有运气。

if ([segue.identifier isEqualToString:@"myAccSegue"]) {
    MyAccountController *destViewController = segue.destinationViewController;
    NSString *s = @"avcd";//[_carImages objectAtIndex: (NSUInteger)index.section ];
    destViewController.recipeName=s;
}

而 MyAccountController 是:

#import <UIKit/UIKit.h>

@interface MyAccountController : UITableViewController

@property NSInteger index;

@property (nonatomic,strong) NSString *recipeName;

@end

在 MyAccountController.m 中我写了@synthesise recipeName。当我运行时,我得到了错误

2013-06-29 23:02:28.962 abcd[9171:c07] -[UIViewController setRecipeName:]: unrecognized selector sent to instance 0x7560cc0

一点调试显示ox7560cc0属于destinationViewController。不知道出了什么问题..

有什么帮助吗?

【问题讨论】:

    标签: ios objective-c uiviewcontroller


    【解决方案1】:

    错误信息

    -[UIViewController setRecipeName:]: 无法识别的选择器发送到实例...

    表示

    MyAccountController *destViewController = segue.destinationViewController;
    

    没有按预期返回MyAccountController,而是返回UIViewController

    一个可能的原因是您没有在情节提要文件中将视图控制器的“自定义类”设置为“MyAccountController”。

    【讨论】:

      猜你喜欢
      • 2014-01-13
      • 2012-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-07
      • 1970-01-01
      • 2019-08-28
      相关资源
      最近更新 更多