// // 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