0
我有一個數組初始化訪問目標C嵌套數組元素
- (void) viewDidLoad {
NSArray *myArray = [NSArray arrayWithObjects:
[NSArray arrayWithObjects:@"item 1-1", @"item 1-2", nil],
[NSArray arrayWithObjects:@"item 2-1", @"item 2-2", nil],
[NSArray arrayWithObjects:@"item 3-1", @"item 3-2", nil],
nil];
}
- (IBAction) someButtonPressed {
NSString *text = // and here I can't figure out how to actually access the value needed
[someLabel setText:text];
}
我需要someLabel文本設置爲「項1-2」值,例如。我怎樣才能做到這一點?
'myArray'必須聲明爲一個實例變量。如果你不知道該怎麼做,請閱讀:http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html – bbum 2010-07-22 20:55:13