//可變字典 NSMutableDictionary *md = [[NSMutableDictionary alloc]initWithCapacity:2]; [md setObject:@"lisi" forKey:@"name"]; [md setObject:@"15" forKey:@"age"]; [md setObject:@"111" forKey:@"age"];//添加鍵值對,若是key已經存在則修改value的值 // NSLog(@"%@",md); for (NSString *key in md) { NSString *name = [md objectForKey:key]; NSLog(@"key = %@",key); NSLog(@"name = %@",name); }