fix bugs in CCDictionary::objectForKey(int/string)

This commit is contained in:
walzer 2012-10-04 09:03:22 +08:00
parent 16afe5b616
commit f1b87ef0e9
1 changed files with 4 additions and 2 deletions

View File

@ -93,10 +93,11 @@ CCObject* CCDictionary::objectForKey(const std::string& key)
{
if (m_eDictType != kCCDictStr)
{
CCAssert(m_eDictType == kCCDictStr, "this dictionary does not use string as key.");
return NULL;
}
CCAssert(m_eDictType == kCCDictStr, "this dictionary does not use string as key.");
CCObject* pRetObject = NULL;
CCDictElement *pElement = NULL;
HASH_FIND_STR(m_pElements, key.c_str(), pElement);
@ -111,10 +112,11 @@ CCObject* CCDictionary::objectForKey(int key)
{
if (m_eDictType != kCCDictInt)
{
CCAssert(m_eDictType == kCCDictInt, "this dictionary does not use integer as key.");
return NULL;
}
CCAssert(m_eDictType == kCCDictInt, "this dictionary does not use integer as key.");
CCObject* pRetObject = NULL;
CCDictElement *pElement = NULL;
HASH_FIND_INT(m_pElements, &key, pElement);