NSMutableDictionary

NSMutableDictionary

网上:
NSMutableDictionary *dict = [NSMutableDictionary dictionary];

[dict setObject:@"John" forKey:@"Firstname"];
[dict setObject:@"Doe" forKey:@"Lastname"];
[dict setObject:@"info@objectgraph.com" forKey:@"Email"];

NSLog(@"%@===aaa", dict);

NSArray *keys = [dict allKeys];

// values in foreach loop
for (NSString *key in keys) {
NSLog(@"%@ is %@",key, [dict objectForKey:key]);
}

[dict removeObjectForKey:@"Email"];

自己:

NSMutableDictionary *d=[[NSMutableDictionary alloc]init];
[d setObject:@"zhang" forKey:@"z"];
[d setObject:@"ming" forKey:@"m"];
[d setObject:@"wei" forKey:@"w"];
NSLog(@"%@",[d objectForKey:@"w"]);
NSArray *keys1=[d allKeys];
for (NSString *key1 in keys1) {
NSLog(@"%@ is %@",key1,[d objectForKey:key1]);
}
[d removeObjectForKey:@"z"];
for (NSString *key1 in keys1) {
NSLog(@"%@ is %@",key1,[d objectForKey:key1]);
}
控制台:
2012-08-22 20:14:13.996 Student[3066:707] {
Email = "info@objectgraph.com";
Firstname = John;
Lastname = Doe;
}===aaa
2012-08-22 20:14:14.090 Student[3066:707] Email is info@objectgraph.com
2012-08-22 20:14:14.125 Student[3066:707] Firstname is John
2012-08-22 20:14:14.126 Student[3066:707] Lastname is Doe
2012-08-22 20:14:14.127 Student[3066:707] wei
2012-08-22 20:14:14.128 Student[3066:707] z is zhang
2012-08-22 20:14:14.129 Student[3066:707] m is ming
2012-08-22 20:14:14.129 Student[3066:707] w is wei
2012-08-22 20:14:14.130 Student[3066:707] z is (null)
2012-08-22 20:14:14.130 Student[3066:707] m is ming
2012-08-22 20:14:14.131 Student[3066:707] w is wei
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值