20

キーと値のペアを保持するを維持してNSMutableDictionaryいます。次に、その中の値ごとにいくつかの操作を実行する必要があります。辞書から値を取得する方法。

// this is NSMutableDIctionary 
NSMutableDictionary *dictobj = [[NSMutableDictionary alloc]init];
 // in methodA

-(void)methodA
{
   //get the value for each key and peform an operation on it.
}

どうやって進める?plzヘルプ

4

3 に答える 3

44
for (id key in dictobj)
{
    id value = [dictobj objectForKey:key];
    [value doSomething];
}
于 2010-02-18T04:07:56.783 に答える
6

私はあなたの質問が何を求めているのか完全にはわかりませんが、あなたは探しているかもしれません:

for (id currentValue in [dictobj allValues])
{
    //stuff with currentValue
}
于 2010-02-18T04:01:13.807 に答える
0
NSArray *array = [viewControllers allValues];
for (int i = 0; i<array.count; i++) {        
    MenuListingVC *vc = array[i];
    [vc tableDataReload];
}
于 2016-01-27T06:07:35.733 に答える