objective-c的NSMutableDictionary对象数据修改测试

来源:互联网 发布:贵阳大数据是传销吗 编辑:程序博客网 时间:2024/05/17 03:35
#import <Foundation/Foundation.h>@interface datTest : NSObject@property(nonatomic, assign) NSString *dat1;@property(nonatomic, assign) NSString *dat2;@end@implementation datTest@synthesize dat1;@synthesize dat2;-(NSString *) description{    return [NSString stringWithFormat:@"1=%@,2=%@",dat1, dat2];}@endint main(int argc, const char * argv[]) {    @autoreleasepool {        // insert code here...        NSLog(@"Hello, World!");        NSMutableDictionary *data = [[NSMutableDictionary alloc] init];        datTest *dt = [[datTest alloc] init];        dt.dat1 = @"123";        [data setValue:dt forKey:@"1"];        dt.dat2 = @"456";        NSLog(@"1 data=%@",data);        datTest *d = [data objectForKey:@"1"];        d.dat2 = @"789";        NSLog(@"2 data=%@",data);    }    return 0;}

结果:

2016-12-06 20:14:32.449751 dataTest[3263:143128] Hello, World!

2016-12-06 20:14:32.450701 dataTest[3263:143128] 1 data={

    1 = "1=123,2=456";

}

2016-12-06 20:14:32.450841 dataTest[3263:143128] 2 data={

    1 = "1=123,2=789";

}

Program ended with exit code: 0


0 0
原创粉丝点击