views:

335

answers:

2

Hello, 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

+1  A: 

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
wher is currentValue declared? of which class object is it?
suse
This is a use of "fast enumeration" (just like the other answer). `currentValue` is declared right in the for-in loop.
andyvn22
A: 
for (id key in dictobj)
{
    id value = [dictobj objectForKey:key];
    [value doSomething];
}
dreamlax