纯学习笔记,呵呵!

初始化NSDictionary:

NSDictionary *dict = [NSDictionary dictionary];

给dictionary赋值:

[dict setValue:[NSString stringWithString:@"test"] forKey:[NSString stringWithString:@"123"]];
[dict setValue:[NSString stringWithString:@"test"] forKey:[NSString stringWithString:@"124"]];
[dict setValue:[NSString stringWithString:@"test"] forKey:[NSString stringWithString:@"125"]];

遍历dictionary:

    for (id key in dataDic)
    {
        NSLog(@"key: %@ value: %@",key, [dataDic objectForKey:key]);
    }