0

我有一个用字典创建的 NSArray:

aMapData = [[NSMutableArray alloc] initWithCapacity:sizeof(jsonResponse)];


for (NSMutableDictionary *dict in jsonResponse) {  

    NSDictionary *row = [NSDictionary dictionaryWithObjectsAndKeys:[dict objectForKey:@"pID"], @"pID", [dict objectForKey:@"Address"], @"Address",  nil];
    [aMapData addObject:row];

  }

它有大约 100 行。

我想获得 pID 列,是迭代的唯一选择,并且:

 [aMapData objectAtIndex:0]

?

先感谢您!

我发现它,不需要数组:

NSArray *idPath = [aMapData valueForKey:@"pID"];
4

1 回答 1

0

是的。否则,您必须将每一列存储在一个单独的数组中。

pID = [[NSMutableArray alloc] init];
address = [[NSMutableArray alloc] init];

for (NSMutableDictionary *dict in jsonResponse) {  
    [pID addObject:[dict objectForKey:@"pID"]];
    [address addObject:[dict objectForKey:@"address"]];
}
于 2012-08-31T13:06:18.890 回答