将多个字典添加到数组输出
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSDictionary *dic1=@{@"name":@"小阳",
@"class":@"IOS6",
@"age":@"24"
};
NSDictionary *dic2=@{@"name":@"小明",
@"class":@"IOS8",
@"age":@"67"
};
NSDictionary *dic3=@{@"name":@"小明",
@"class":@"IOS6",
@"age":@"67"
};
NSMutableArray *muarr=[NSMutableArray array];
[muarr addObject:dic1];
[muarr addObject:dic2];
[muarr addObject:dic3];
//for(int i=0;i<muarr.count;i++){
// for(id obj in muarr){
for (NSDictionary *dic in muarr) {
// NSDictionary *dic = obj;
// NSLog(@"班级:%@,姓名:%@,年龄%@",[dic objectForKey:@"class"],[dic objectForKey:@"name"],[dic objectForKey:@"age"]);
NSLog(@"班级:%@,姓名:%@,年龄%@",dic[@"class"],dic[@"name"],dic[@"age"]);
}
}
return 0;
}