本文介绍了如何在Objective-C中获取字典中每个键的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在维护一个 NSMutableDictionary
,它包含键和值对.现在我需要对其中的每个值执行一些操作.如何从字典中检索值.
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.
}
如何进行?请帮忙
推荐答案
for (id key in dictobj)
{
id value = [dictobj objectForKey:key];
[value doSomething];
}
这篇关于如何在Objective-C中获取字典中每个键的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!