• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
Yesi-悦思
"(program(computers) == *art) ? so : what" 修身岂为名传世,作事惟思利及人
博客园    首页    新随笔    联系   管理    订阅  订阅

NSMutableDictionary

//NSMutableDictionary

#import “Student.h”

#pragma mark use of NSMutableDictionary

void dictUse(){

Student *stu1=[Student studentWithName:@”stu1”];

Student *stu2=[Student studentWithName:@”stu2”];

//create a mutable void dict

NSMutableDictionary  *dict=[NSMutableDictionary dictionary];

//add elements

//add student class

//Way1:

11

//If not check that ,in current project only quote

//if just quote ,never check move to trash,it will delete original file.

1

//Way2

//Select the files and move to your current project

 1

//Personal opinion better copy

1

1

[dict setObject:stu1  forKey:@“k1”];//counter=2

NSLog(@”stu1:zi%”,[stu1 retainCount]);

[dict setObject:stu2 forKey:@”k2”];

}

1

//check which files are added to your project

1

//Tips

//If you import some files from outside,check whether they are compiled.

//When the dict is destroied , all the keys and values  inside will be reduce counter

//Add content of other dictionary into current dictionary

NSDictory *other=[NSDictionary dictionaryWithObject:@”v2” forKey:@”k2”];

[dict addEntriesFromDictionary:other];

//delete element

[dict removeAllObjects];// Remove all keys and values

[dict removeObjectForKey:@”k1”];

// remove object according to key stu1

//Remove objects base on multi-keys

[dict removeObjectsForKeys:[NSArray arrayWithObject:@”k1”]];

posted @ 2015-06-04 16:15  悦思  阅读(271)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3