#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSDictionary *[email protected]{@"name":@"小明",
@"class":@"IOS6",
@"age":@"24"
};
NSDictionary *[email protected]{@"name":@"小红",
@"class":@"IOS8",
@"age":@"23"
};
NSMutableArray *num=[NSMutableArray array];
[num addObject:dic];
[num addObject:dic1];
for (int i=0; i<num.count; i++) {
NSDictionary *dic2=num[i];
NSLog(@"%@ %@ %@",[dic2 objectForKey:@"name"],[dic2 objectForKey:@"class"],[dic2 objectForKey:@"age"]);
//简便写法
// NSLog(@"%@ %@ %@",dic2[@"name"],dic2[@"class"],dic2[@"age"]);
}
}
return 0;
}
时间: 2024-12-28 12:06:18