Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 486
suse Avatar asked Feb 18 '10 03:02

suse


2 Answers

for (id key in dictobj)
{
    id value = [dictobj objectForKey:key];
    [value doSomething];
}
like image 197
dreamlax Avatar answered Nov 12 '22 09:11

dreamlax


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
}
like image 20
andyvn22 Avatar answered Nov 12 '22 09:11

andyvn22