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