Objective c 是否可以在NSDictionary对象上创建for?

Objective c 是否可以在NSDictionary对象上创建for?,objective-c,cocoa-touch,for-loop,Objective C,Cocoa Touch,For Loop,这个问题解释了一切 例如,如果我有一本这样的词典 第一个=(“a”、“b”、“c”), 第二个=(“d”、“e”、“f”) 第三个=(“g”、“h”、“i”) 我想在他们身上做一些操作。可能吗 谢谢你终于找到了 for (id theKey in theDictionary) { id theObject = [[theDictionary objectForKey:theKey] retain]; } 作为对解决方案的补充:如果您只对对象感兴趣,而对键不感兴趣,那么您也可以使用for

这个问题解释了一切

例如,如果我有一本这样的词典 第一个=(“a”、“b”、“c”), 第二个=(“d”、“e”、“f”) 第三个=(“g”、“h”、“i”)

我想在他们身上做一些操作。可能吗

谢谢你终于找到了

for (id theKey in theDictionary) {
    id theObject = [[theDictionary objectForKey:theKey] retain];
}

作为对解决方案的补充:如果您只对对象感兴趣,而对键不感兴趣,那么您也可以使用
for(id obj in[theDictionary valueEnumerator]){…}