1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| NSDictionary *dict=[NSDictionary dictionaryWithObject:@"jack" forKey:@"name"]; id obj=[dict objectForKey:@"name"]; NSLog(@"%@",obj); NSArray *keys=@[@"name",@"address"]; NSArray *objects=@[@"jack",@"北京"]; NSDictionary *dicts=[NSDictionary dictionaryWithObjects:keys forKeys:objects]; NSDictionary *dicts2=[NSDictionary dictionaryWithObjectsAndKeys: @"jack",@"name", @"北京",@"address", @"11111",@"qq",nil]; id obj2=[dicts2 objectForKey:@"qq"]; NSLog(@"%@",obj2); NSDictionary *dict3=@{@"name": @"jack",@"address": @"北京"}; id obj3=[dict3 objectForKey:@"name"]; NSLog(@"%@",obj3); id obj4=dict3[@"name"]; NSLog(@"%@",obj4); NSLog(@"%d",dict3.count);
|