开发者

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

开发者 https://www.devze.com 2022-12-20 07:22 出处:网络
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.

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开发者_StackOverflow社区 
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


for (id key in dictobj)
{
    id value = [dictobj objectForKey:key];
    [value doSomething];
}


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
}


NSArray *array = [viewControllers allValues];
for (int i = 0; i<array.count; i++) {        
    MenuListingVC *vc = array[i];
    [vc tableDataReload];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消