objective-c二维数组 objective-c多维数组 iPhone 开发

//构造二维数组

NSArray *array = [[NSArray alloc] initWithObjects:
[NSArray arrayWithObjects:@"iOS",@"android",@"C",@"C++",@"OC",@"JAVA", nil],
[NSArray arrayWithObjects:@"php",@"c#",@"FMDB",@"sqlite",@"odbc",@"photoshop", nil],
[NSArray arrayWithObjects:@"javascript",@"xml",@"html",@"cocos2D",@"u3d",@"sjjg", nil],
nil];

//打印二维数组
NSLog(@"%@",[[array objectAtIndex:1] objectAtIndex:2]);

//构造多维数组
NSArray *array = [[NSArray alloc] initWithObjects:
[NSArray arrayWithObjects:
[NSArray arrayWithObjects:@"生活",@"生存",@"生命",@"生长",@"生产",@"生气", nil],
[NSArray arrayWithObjects:@"美丽",@"美好",@"美人",@"美剧",@"美声",@"美琪", nil],
nil],
[NSArray arrayWithObjects:@"海洋",@"湖泊",@"江河",@"小溪",@"河流",@"流水", nil],
[NSArray arrayWithObjects:@"西施",@"昭君",@"貂蝉",@"玉环",@"妲己",@"慈禧", nil],
nil];

//打印多维数组
NSLog(@"%@",[[[array objectAtIndex:0] objectAtIndex:1] objectAtIndex:2]);

[/code]

你可能感兴趣的:(Objective-c)