从可变字典中删除条目
- removeObjectForKey:
从字典中删除给定的键及其关联值。
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:@{@"key1":@"Easy",@"key2": @"Tutorials"}];
[dict removeObjectForKey:@"key1"];
NSLog(@"%@",dict);
OUTPUT
{
key2 = Tutorials;
}
- removeAllObjects
清空其条目的字典。
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:@{@"key1":@"Eezy",@"key2": @"Tutorials"}];
[dict removeAllObjects];
NSLog(@"%@",dict);
OUTPUT
{
}
- removeObjectsForKeys:
从给定数组中的元素指定的字典条目中删除。
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:@{@"key1":@"Easy",@"key2": @"Tutorials"}];
[dict removeObjectsForKeys:@[@"key1"]];
NSLog(@"%@",dict);
OUTPUT
{
key2 = Tutorials;
}