How to read .plist file with c++ code?

Hi,all:
I’m convert these obj-c code to c++

NSString plistPath = pathForResource:"xxx" ofType:“plist”];
NSArray
animImages = [NSArray arrayWithContentsOfFile:plistPath];
NSMutableArray **animFrames = ;
for {
spriteFrameByName:animImage]];
}

So I use these code below:
CCDictionary<std::string, CCObject *>**testPlist = CCFileUtils::dictionaryWithContentsOfFile(CCFileUtils::dictionaryWithContentsOfFile(“xxx.plist”);

but crash without any log. :frowning:

How can I do?

Hi,

I don’t understand why do you have CCFileUtils::dictionaryWithContentsOfFile for two times ?

I’ve done it like this

CCDictionary<std::string, CCObject*> *plistDictionary = CCFileUtils::dictionaryWithContentsOfFile);
if {
CCLOG (“Error reading plist: %s.plist”, className);
}
CCDictionary<std::string, CCObject
>*animationSettings = (CCDictionary<std::string, CCObject>*)plistDictionary->objectForKey(animationName);
if (animationSettings == NULL) {
CCLOG (“Could not locate AnimationWithName:%s”,animationName);
}

Hi I too facing same issue.

Doyang Yang wrote:

Hi,all:
I’m convert these obj-c code to c++
>
NSString plistPath = pathForResource:"xxx" ofType:“plist”];
NSArray
animImages = [NSArray arrayWithContentsOfFile:plistPath];
NSMutableArray **animFrames = ;
for {
spriteFrameByName:animImage]];
}
>
>
So I use these code below:
>
CCDictionary<std::string, CCObject *>**testPlist = CCFileUtils::dictionaryWithContentsOfFile(CCFileUtils::dictionaryWithContentsOfFile(“xxx.plist”);
>
but crash without any log. :frowning:
>
How can I do?

Hi I too facing same issue.

as of my knowledge,

Check the source of plist file.
plist source can be josn or xml format.

if plist source in xml format the it’ll work. if it is json, then we get the same problem as you got.

plist can also be in binary format. If you need, I can share a parser of binary format that I used for reading localisation files (http://www.cocos2d-x.org/boards/6/topics/2951?r=7961#message-7961)