#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
NSMutableDictionary *data = [[NSMutableDictionary alloc] init];
[data setValue:@"123" forKey:@"1"];
[data setValue:@"456" forKey:@"2"];
NSLog(@"data=%@",data);
[data setValue:@"789" forKey:@"2"];
NSLog(@"data=%@",data);
[data setValue:nil forKey:@"2"];
NSLog(@"data=%@",data);
id d = [data objectForKey:@"1"];
NSLog(@"1 = %@",d);
}
return 0;
}
结果:
2016-12-06 18:10:44.821141 dataTest[3088:124274] Hello, World!
2016-12-06 18:10:44.825078 dataTest[3088:124274] data={
1 = 123;
2 = 456;
}
2016-12-06 18:10:44.825865 dataTest[3088:124274] data={
1 = 123;
2 = 789;
}
2016-12-06 18:10:44.825925 dataTest[3088:124274] data={
1 = 123;
}
2016-12-06 18:10:44.826076 dataTest[3088:124274] 1 = 123
Program ended with exit code: 0