陈斌彬的技术博客

Stay foolish,stay hungry

NSMutableDictionary

注: iOS 6 新的快捷初始化写法:

NSDictionary:

NSDictionary *dic = @{@"键":@"值",@"键1":@"值1"};  

NSMutableDictionary:

NSMutableDictionary *MDic = [@{@"键":@"值",@"键1":@"值1"} mutableCopy];  

1:基础初始化

NSMutableDictionary *muDicAsyncImage = [[NSMutableDictionary alloc] init];  

2:为字典添加对象(键与值都是 id 接受任何类型)

[muDicAsyncImage setObject:@"值" forKey:@"键"]; 

3:通过键取得值对象

NSString *str= [muDicAsyncImage objectForKey:@"键"]; 

4:删除某个对象

[muDicAsyncImage removeObjectForKey: @"键"];