如果我想从View1获取一个Label.text, 所以我在firstView.h中设置
@interface RootViewController : UITableViewController {
NSMutableArray *menuList;
}
@property(nonatomic,retain)NSMutableArray *menuList;
@end
@interface SecondViewController : UIViewController <UIPickerViewDelegate,UIPickerViewDataSource> {
UILabel *comboView;
}
@property (nonatomic,retain)UILabel *comboView;
@end
在secondView.m
中FirstViewController *firstViewController = [[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:nil];
[firstViewController.menuList addObject:comboView.text];
但是当我想在firstView(self.menuList)中从menuList获取对象时 它变成“无效”!!!
有什么问题? 感谢
迷你
答案 0 :(得分:1)
提供的代码非常有限,您是否记得在添加对象之前初始化'menuList'? Objective C允许您将对象添加到未初始化的数组中,因此很容易出错。