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.
}

如何进行?请帮助

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 回答