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);

value ->getCString());

}

cocos2d-x CCDictionary的遍历

相关文章: