像这样的东西:
NSMutableDictionary* md = [@{ @"user1" : @{ @"phone Number" : @"123-123-1234",
@"email" : @"me@me.com",
@"title" : @"sales" },
@"user2" : @{ @"phone Number" : @"123-123-1234",
@"email" : @"me2@me.com",
@"title" : @"support" },
@"user3" : @{ @"phone Number" : @"123-123-1234",
@"email" : @"me3@me.com",
@"title" : @"management" }
} mutableCopy];
或者:
NSMutableDictionary* md2 = [NSMutableDictionary dictionaryWithDictionary:
@{ @"user1" : @{ @"phone Number" : @"123-123-1234",
@"email" : @"me@me.com",
@"title" : @"sales" },
@"user2" : @{ @"phone Number" : @"123-123-1234",
@"email" : @"me2@me.com",
@"title" : @"support" },
@"user3" : @{ @"phone Number" : @"123-123-1234",
@"email" : @"me3@me.com",
@"title" : @"management" }
} ];
如果您希望每个内部字典是可变的,您可以应用相同的模式:
NSMutableDictionary* md3 = [@{ @"user1" : [@{ @"phone Number" : @"123-123-1234",
@"email" : @"me@me.com",
@"title" : @"sales" } mutableCopy],
@"user2" : [@{ @"phone Number" : @"123-123-1234",
@"email" : @"me2@me.com",
@"title" : @"support" } mutableCopy],
@"user3" : [@{ @"phone Number" : @"123-123-1234",
@"email" : @"me3@me.com",
@"title" : @"management" } mutableCopy]
} mutableCopy];