YIem`s Blog -心比天高命比纸薄-链接找不到的请在站内搜索内容!

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

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »