From cfb5de2900997b10b7f10c7cac85a84beafa2f6a Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 18 Sep 2013 16:06:39 +0800 Subject: [PATCH] Fixing crash after changing Dictionary::createWithContentOfFile() to return autorelease object. [ci skip]. --- cocos2dx/platform/apple/CCFileUtilsApple.mm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/cocos2dx/platform/apple/CCFileUtilsApple.mm b/cocos2dx/platform/apple/CCFileUtilsApple.mm index 5aae811b52..34de65fee6 100644 --- a/cocos2dx/platform/apple/CCFileUtilsApple.mm +++ b/cocos2dx/platform/apple/CCFileUtilsApple.mm @@ -307,18 +307,20 @@ std::string FileUtilsApple::getFullPathForDirectoryAndFilename(const std::string Dictionary* FileUtilsApple::createDictionaryWithContentsOfFile(const std::string& filename) { std::string fullPath = fullPathForFilename(filename); - NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()]; - NSDictionary* pDict = [NSDictionary dictionaryWithContentsOfFile:pPath]; + NSString* path = [NSString stringWithUTF8String:fullPath.c_str()]; + NSDictionary* dict = [NSDictionary dictionaryWithContentsOfFile:path]; - if (pDict != nil) + if (dict != nil) { - Dictionary* pRet = Dictionary::create(); - for (id key in [pDict allKeys]) { - id value = [pDict objectForKey:key]; - addValueToDict(key, value, pRet); + auto ret = new Dictionary(); + ret->init(); + + for (id key in [dict allKeys]) { + id value = [dict objectForKey:key]; + addValueToDict(key, value, ret); } - return pRet; + return ret; } else {