fixed #2260: make CCDictionary::createWithContentsOfFile() return NULL when the file is missing

This commit is contained in:
minggo 2013-06-06 12:50:42 +08:00
parent a63f67afac
commit a8fe210c7e
1 changed files with 13 additions and 6 deletions

View File

@ -307,13 +307,20 @@ CCDictionary* CCFileUtilsIOS::createCCDictionaryWithContentsOfFile(const std::st
NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()];
NSDictionary* pDict = [NSDictionary dictionaryWithContentsOfFile:pPath];
CCDictionary* pRet = new CCDictionary();
for (id key in [pDict allKeys]) {
id value = [pDict objectForKey:key];
addValueToCCDict(key, value, pRet);
if (pDict != nil)
{
CCDictionary* pRet = new CCDictionary();
for (id key in [pDict allKeys]) {
id value = [pDict objectForKey:key];
addValueToCCDict(key, value, pRet);
}
return pRet;
}
else
{
return NULL;
}
return pRet;
}
bool CCFileUtilsIOS::writeToFile(CCDictionary *dict, const std::string &fullPath)