我试图在 for 循环中获取 NSMutableDictionary 的 KEY 的名称。但是我很沮丧,因为我找不到正确的函数来只获取 KEY 而不必引用对象。
我会很感激一些指导。我想要的关键是一个字符串
NSMutableDictionary* myMutaDictionary = @{ @"theValeIwantOne":@{key:value},
@"theValeIwantTwo":@{key:value}
};
for (NSDictionary* myDictionary in myMutaDictionary) {
NSString* key1 = //... code to get theValeIwantOne and theValeIwantTow;
}
我来自 PHP,这个操作很简单
foreach ($variable as $key => $value) {
$thisIsMyKeyName = $key;
$thisIsTheValueOfThatKey = $value;
}