我想在for循环中获取NSMutableDictionary的KEY的名称。但是我感到沮丧,因为我找不到合适的函数来获取KEY而不必引用对象。如何获取NSMutableDictionary的键的名称
我将不胜感激一些指导。我想关键是一个String
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;
}
这PHP代码是不就像它看起来那么简单... –
它的一个经典的foreach循环在php –
正是如此。 PHP中的foreach循环在状态方面存在一些主要问题。你不能为同一个数组嵌套'foreach'循环。 –