访问数组中的对象?

时间:2011-08-30 16:39:45

标签: objective-c arrays nsstring

我的数组设置如下:

NSMutableArray *array = [[NSArray alloc] initWithObjects: @"Item 1", @"Item 2", @"Item 3", @"Item 4", @"Item 5", nil];

我想访问数组的内容以在NSString中显示它们,但我不确定要使用什么,例如:

[NSString stringWithFormat:@"%c", [objectAtIndex:0]];
[NSString stringWithFormat:@"%c", [objectAtIndex:1]];

但我的数组是在- (void)viewDidLoad中声明的,我需要在- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath中访问它们 - 我如何访问它们并在NSString中显示它们?

1 个答案:

答案 0 :(得分:1)

使数组成为实例变量。然后,您可以从任何实例方法访问它。

相关问题