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

rav*_*avi 1 objective-c uiviewcontroller ios

我(来自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;
}
Run Code Online (Sandbox Code Playgroud)

和MyAccountController是:

#import <UIKit/UIKit.h>

@interface MyAccountController : UITableViewController

@property NSInteger index;

@property (nonatomic,strong) NSString *recipeName;

@end
Run Code Online (Sandbox Code Playgroud)

在MyAccountController.mi中写道@synthesise recipeName.当我跑我得到错误

2013-06-29 23:02:28.962 abcd[9171:c07] -[UIViewController setRecipeName:]: unrecognized selector sent to instance 0x7560cc0
Run Code Online (Sandbox Code Playgroud)

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

有什么帮助吗?

Mar*_*n R 21

错误消息

-[UIViewController setRecipeName:]: unrecognized selector sent to instance ...

表明

MyAccountController *destViewController = segue.destinationViewController;
Run Code Online (Sandbox Code Playgroud)

没有MyAccountController按预期返回,但是a UIViewController.

可能的原因是您没有将故事板文件中的视图控制器的"自定义类"设置为"MyAccountController".