20

I'm maintaining a NSMutableDictionary which holds key and value pair.Now i need to perform some operation for each value in it.How to retrive value from dictionary.

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

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

How to proceed? plz help

Venk
  • 5,949
  • 9
  • 41
  • 52
suse
  • 10,503
  • 23
  • 79
  • 113

3 Answers3

44
for (id key in dictobj)
{
    id value = [dictobj objectForKey:key];
    [value doSomething];
}
dreamlax
  • 93,976
  • 29
  • 161
  • 209
6

I'm not entirely clear what your question is asking, but you might be looking for:

for (id currentValue in [dictobj allValues])
{
    //stuff with currentValue
}
andyvn22
  • 14,696
  • 1
  • 52
  • 74
0
NSArray *array = [viewControllers allValues];
for (int i = 0; i<array.count; i++) {        
    MenuListingVC *vc = array[i];
    [vc tableDataReload];
}
Undo
  • 25,519
  • 37
  • 106
  • 129
Ravi Kumar
  • 1,356
  • 14
  • 22