首页 > 其他 > 详细

NSMutableDictionary可变字典 容量自动增加

时间:2015-12-20 22:35:38      阅读:303      评论:0      收藏:0      [点我收藏+]
//
//  main.m
//  NSMutableDIctionary
//
//  Created by MAC on 15/12/20.
//  Copyright © 2015年 MAC. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        //继承NSDictionary
        NSMutableDictionary *mdict = [NSMutableDictionary dictionaryWithCapacity:10];
        [mdict setObject:@"ios" forKey:@"1"];
         [mdict setObject:@"Android" forKey:@"2"];
         [mdict setObject:@"cocos2dx" forKey:@"3"];
        NSLog(@"%@",mdict);
        //删除
        //[mdict removeObjectForKey:@"2"];
         NSLog(@"%@",mdict);
       
        NSLog(@"%@", [mdict objectForKey:@"2"]);
        NSArray *array1 = @[@"a",@"b",@"c"];
        NSArray *value = @[@"淘宝",@"京东",@"苏宁易购"];
       mdict = [NSMutableDictionary dictionaryWithObjects:value forKeys:array1];
   
        //删除一段value
        [mdict removeObjectsForKeys:@[@"2",@"3"]];
      NSLog(@"%@",mdict);
        
    }
    return 0;
}

 

NSMutableDictionary可变字典 容量自动增加

原文:http://www.cnblogs.com/WJR12/p/5061818.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!