首页 > 代码库 > [OC Foundation框架 - 11] NSMutableDictionary
[OC Foundation框架 - 11] NSMutableDictionary
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。