标签:
NSDictionary * dic = [NSDictionary dictionaryWithObjectsAndKeys:@"object1",@"key1",@"object2",@"key2",@"object3",@"key3", nil];
1.获得所有的keys:
NSLog(@"value = %@",[dic allKeys]);
2.获得所有的objects:
NSLog(@"object = %@",[dic allValues]);
3.获得一个object的所有keys:
NSLog(@"object2 = %@",[dic allKeysForObject:@"123"]);
4.使用遍历器遍历:
NSEnumerator * enumerator = [dic keyEnumerator];
NSEnumerator * enumerator2 = [dic objectEnumerator];
id object;
// for (object in enumerator) {
// NSLog(@"value11 = %@",object);
// }
while (object = [enumerator nextObject]) {
NSLog(@"value22 = %@",object);
}
for和while使用其中一个就可以。
标签:
原文地址:http://www.cnblogs.com/tanglimei/p/4545551.html