OC-可变字典(NSMutableDictionary)操作

2016-01-05 19:28:53

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"]);

当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »