这是创建该字典的旧的、冗长的方法(有一种新的语法,使用 Objective-C 文字,但是它们不是可变的,所以我选择了这种方法):
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
[dict setObject:[NSNumber numberWithInt:123] forKey:@"UserId"];
[dict setObject:@"blue" forKey:@"UserType"];
NSMutableArray *acts = [[NSMutableArray alloc] init];
[acts addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:3], @"ActId",
[NSNumber numberWithInt:1], @"Time",
nil]];
[acts addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:1], @"ActId",
[NSNumber numberWithInt:6], @"Time",
nil]];
[dict setObject:acts forKey:@"UserActs"];