NSDictionary 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: @""];  

 

posted on 2015-01-29 16:41  奋进的闹钟  阅读(151)  评论(0编辑  收藏  举报

导航