标签:
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSNumber *num=[NSNumber numberWithInt:100];
NSDictionary *dic=[NSDictionary dictionaryWithObject:num forKey:@"money"];
NSDictionary *dics=[NSDictionary dictionaryWithObjectsAndKeys:@"Jay",@"name",@"22",@"age",@"F",@"gender",nil];
NSDictionary *dic1=@{@"name":@"White",
@"age":@"23",
@"gender":@"M"};
NSDictionary *dic2=[NSDictionary dictionaryWithDictionary:dic1];
NSLog(@"%@",dic);
//key-value共有多少对
NSInteger count=[dic2 count];
NSLog(@"count=%ld",count);
//获取字典内value值
NSString *name=[dic2 objectForKey:@"name"];
NSLog(@"根据key找value--姓名:%@",name);
//获取字典内所有的value
NSArray *values=[dic2 allValues];
for (id str in values) {
NSLog(@"%@",str);
}
//获取字典内所有的key
NSArray *keys=[dic2 allKeys];
for (id str in keys) {
NSLog(@"%@",str);
}
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/shaowenlong/p/5121808.html