在类ViewController5中定义了成员变量: NSMutableArray *data。
在类ItemInputController中使用到了ViewController5中的data变量,访问方式是:[xxx.data removeObjectAtIndex:index];但是编译提示错误:”Accesing unknown 'data' getter method“。
明明在ViewController5类中定义了data啊!!!!
原来犯了老毛病,如果是C++或者C中的结构体,定义了就可以直接饮用,但是objetive-c中呢?
xxx.data 其实调用的是类ViewController5 中的 getData 方法,而类中没有定义该方法,当然无法识别而报错。
解决方案:将data定义为ViewController5的属性即可:
@property (nonatomic, retain) NSMutableArray * data;
在类的实现中:
@synthesize data.
系统将在编译时自动生成data的get方法,因此可以顺利通过。
如果显示定义get方法也应该可以。。。。