码迷,mamicode.com
首页 > 其他好文 > 详细

[OC Foundation框架 - 11] NSMutableDictionary

时间:2014-11-24 20:30:27      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   ar   color   使用   sp   for   on   

 
 1 void dicUse()
 2 {
 3     NSMutableDictionary *dic = [NSMutableDictionary dictionary];
 4     Student *stu1 = [Student studentWithName:@"Simon"];
 5    
 6     NSLog(@"stu1:%zi", [stu1 retainCount]);
 7     [dic setObject:stu1 forKey:@"k1"];
 8     NSLog(@"stu1:%zi", [stu1 retainCount]);
 9    
10     [dic setObject:[Student studentWithName:@"Joke"] forKey:@"k2"];
11     NSLog(@"%@", dic);
12    
13     [dic removeObjectForKey:@"k1"];
14     NSLog(@"after remove stu1:%zi", [stu1 retainCount]);
15    
16     NSMutableDictionary *dic2 = [NSMutableDictionary dictionary];
17     [dic2 addEntriesFromDictionary:dic];
18     NSLog(@"dic2: %@", dic2);
19 }
 
NSMutableDictionary不允许使用简化的集中初始化方法创建
error:
1         NSMutableDictionary *d11_1 = @{@"姓名":@"张三", @"年龄":@"21", @"性别":@""};
 
 
 
 
 
 

[OC Foundation框架 - 11] NSMutableDictionary

标签:style   blog   io   ar   color   使用   sp   for   on   

原文地址:http://www.cnblogs.com/hellovoidworld/p/4119414.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!