cocos2d-x CCDictionary的遍历

CCDictionary的遍历不是用for或foreach,而是cocos2d-x自己封装了一个遍历方法CCDICT_FOREACH(__dict__, __el__)

用法:

CCDictionary * pDict = CCDictionary::create();

pDict->setObject(CCString::create("value1"), "key1");

pDict->setObject(CCString::create("value2"), "key2");

CCDictElement * pElement;

CCDICT_FOREACH(pDict, pElement)

{

const char * key = pElement->getStrKey();

CCString * value = (CCString *)pElement->getObject();

CCLog(key);

CCLog(value ->getCString());

}

posted @ 2014-11-21 14:47  猿走天下  阅读(1737)  评论(0编辑  收藏  举报