NSMutableDictionary

//
//  main.m
//  NSMutableArray
//
//  Created by rayln on 13-9-7.
//  Copyright (c) 2013年 rayln. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{

    @autoreleasepool {
        NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"v1", @"k1", @"v2", @"k2", @"v3", @"k3", nil];
        //往dic中加入新的key和value
        [dic setObject:@"v4" forKey:@"k4"];
        
        //删除某个对象
        [dic removeObjectForKey:@"k3"];
        //添加一个新的字典到这个字典里面
        [dic addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys:@"v5", @"k5", nil]];
        
        NSLog(@"%@", dic);
        
    }
    return 0;
}

你可能感兴趣的:(Objective-C)