zoukankan      html  css  js  c++  java
  • 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”]];

  • 相关阅读:
    代码生成器
    怎样成为优秀的软件模型设计者[转]
    2010年部分节假日安排的通知
    Web开发工具整理
    JS模版
    Timer_MinBytesPerSecond,Timer_ConnectionIdle解决办法
    [原]Asp.Net提交后,刷新时事件触发问题解决
    [转]JS日期选择控件
    知道了sa密码,控制服务器
    调试
  • 原文地址:https://www.cnblogs.com/yesihoang/p/4552157.html
Copyright © 2011-2022 走看看