用键和对象枚举NSDictionary,PHP样式 [英] Enumerate NSDictionary with keys and objects, PHP style
本文介绍了用键和对象枚举NSDictionary,PHP样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道您可以使用 NSEnumerator
枚举 NSMutableDictionary
的键或值。可以一起做吗?我正在寻找类似于PHP foreach
枚举器的东西,例如:
I know you can Enumerate the keys or values of NSMutableDictionary
using NSEnumerator
. Is it possible to do both together? I'm looking for something similar to the PHP foreach
enumerator like:
foreach ($dictionary as $key => $value);
推荐答案
也许看看NSDictionary的方法:
Perhaps look into NSDictionary's method:
enumerateKeysAndObjectsUsingBlock:(void (^)(id key, id obj, BOOL *stop))
如果您不熟悉C / Objective-C中的块,那么这是一个很好的教程: http://thirdcog.eu/pwcblocks/
If you're not familiar with blocks in C/Objective-C, this is a good tutorial: http://thirdcog.eu/pwcblocks/
这篇关于用键和对象枚举NSDictionary,PHP样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文