NSDictionary *dict = [[NSDictionary alloc]initWithObjectsAndKeys:@"one",@"1",@"two",@"2",@"three",@"3", nil];
NSLog(@"1---%@",dict);
// 字典的遍历
NSEnumerator *enumerator = [dict objectEnumerator];
id obj ;
while (obj = [enumerator nextObject]) {
NSLog(@"2----%@",obj);
}
NSString *str = [dict objectForKey:@"2"];
NSLog(@"3----%@",str);
for (id obj in dict) {
NSLog(@"4-----%@",obj);
}
/* 可变字典*/
NSMutableDictionary *mudict = [[NSMutableDictionary alloc]init];
[mudict setObject:@"one" forKey:@"1"];
[mudict setObject:@"two" forKey:@"2"];
[mudict setObject:@"three" forKey:@"3"];
NSLog(@"5---%@",mudict);
[mudict removeObjectForKey:@"2"];
NSLog(@"6---%@",mudict);