小编ala*_*aro的帖子

在iOS类扩展中定义属性

我想在类扩展中向UITableView添加一个属性:

@interface UITableViewController ()

@property NSString *entityString;

@end
Run Code Online (Sandbox Code Playgroud)

然后我导入扩展,然后在UITableViewController的子类中使用entityString属性:

@implementation CustomerTableViewController

- (void)viewDidLoad {
    self.entityString = @"Customer";
    ...
    [super viewDidLoad];
}
...
Run Code Online (Sandbox Code Playgroud)

Apple文档说:

编译器将自动合成主类实现中的相关访问器方法(...).

但是当我尝试执行它时,我收到此错误:

- [CustomerTableViewController setEntityString:]:无法识别的选择器发送到实例0x737b670

我究竟做错了什么?也许子类无法访问该属性?

objective-c automatic-ref-counting ios5.1

12
推荐指数
3
解决办法
1万
查看次数