OC-可变字典(NSMutableDictionary)操作

OC-可变字典(NSMutableDictionary)操作

// 可变字典创建
NSMutableDictionary *mdic = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"卞一", @"name", @"男", @"sex", @"啪啪啪", @"hobby", nil];
NSLog(@"%@", [mdic objectForKey:@"name"]);
// 创建空字典(开辟空间)
NSMutableDictionary *mdic_1 = [NSMutableDictionary dictionary];
// 添加/修改
[mdic setObject:@"YIem" forKey:@"name_name"];
NSLog(@"%@", [mdic objectForKey:@"name_name"]);
// 删除
[mdic removeObjectForKey:@"name"];
NSLog(@"%@", [mdic objectForKey:@"name"]);
// 查询-访问
NSLog(@"%@", [mdic objectForKey:@"sex"]);

屏幕快照 2016-01-05 下午7.25.29.png

标签: none

添加新评论

Title - Artist
0:00