2011-01-14 58 views
0

如果我想從視圖1獲得一個Label.text, 所以我在firstView.h我怎麼能拿對象從另一個類

@interface RootViewController : UITableViewController { 
NSMutableArray *menuList; 
} 
@property(nonatomic,retain)NSMutableArray *menuList; 

@end 

設置secondView.h

@interface SecondViewController : UIViewController <UIPickerViewDelegate,UIPickerViewDataSource> { 

UILabel *comboView; 

} 
@property (nonatomic,retain)UILabel *comboView; 
@end 

in secondView.m

FirstViewController *firstViewController = [[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:nil]; 
[firstViewController.menuList addObject:comboView.text]; 

但是當我想從menuList中的firstView(self.menuList)中獲取對象時 它變成了「null」!

有什麼問題? 感謝

迷你

+0

如果您需要一些幫助,請將您的代碼標記爲示例代碼。 – 2011-01-14 10:38:17

回答

1

提供的代碼是非常有限的,你記得添加對象之前初始化「菜單列表」? Objective C允許您將對象添加到未初始化的數組中,因此很容易犯一個錯誤。

+0

這也是我的猜想。 – benwong 2011-01-15 12:13:39

相關問題