How to get the value for each key in dictionary in Objective-C?

suse picture suse · Feb 18, 2010 · Viewed 51.5k times · Source

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

Answer

dreamlax picture dreamlax · Feb 18, 2010
for (id key in dictobj)
{
    id value = [dictobj objectForKey:key];
    [value doSomething];
}