-
<span style="font-size:24px;">
-
-
-
-
-
NSLog(@"Hello, World!");
-
-
-
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"zhiyuan",@"name",@20,@"shengao",@12,@"age", nil nil];
-
NSLog(@"%@",dic);
-
-
-
NSDictionary *dic1 = [[NSDictionary alloc]initWithObjectsAndKeys:@"zhiyuan",@"name",@20,@"shengao",@12,@"age", nil nil];
-
-
NSLog(@"%@",dic1);
-
-
-
NSLog(@"%lu",[dic count]);
-
-
NSLog(@"%@",[dic allKeys]);
-
-
-
NSLog(@"%@",[dic valueForKey:@"name"]);
-
NSLog(@"%@",[dic valueForKey:@"shengao"]);
-
NSNumber *a = [dic valueForKey:@"age"];
-
NSLog(@"%@",a);
-
-
-
-
for (NSString *key in dic) {
-
NSLog(@"%@",[dic objectForKey:key]);
-
}
-
-
-
NSMutableDictionary *dic5 = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"xiaoguang",@"guanggun1",@"xiaomeng1",@"guanggun2",@"xiaomeng2", @"guanggun3",nil];
-
-
NSLog(@"%ld",[dic5 count]);
-
-
[dic5 removeObjectForKey:@"guanggun1"];
-
NSLog(@"%@",dic5);
-
[dic5 removeAllObjects];
-
NSLog(@"%@",dic5);
-
-
-
[dic5 setObject:@"chengjie" forKey:@"guanggui1"];
-
NSLog(@"%@",dic5);
-
-
-
[dic5 setObject:@"xiaocui" forKey:@"guanggui1"];
-
NSLog(@"%@",dic5);
-
-
</span>
字典基础总结,初学者必备,布布扣,bubuko.com
字典基础总结,初学者必备
原文:http://blog.csdn.net/chenhongyi_1992/article/details/38579801