issue when getting value from plist file

issue when getting value from plist file
0.0 0


Hi all,
It seems that there are something wrong when I getting values from my plist file.
I get values with the following code.

    CCDictionary *dict = CCFileUtils::dictionaryWithContentsOfFile(path);
    CCDictionary *scene = (CCDictionary* )(dict -> objectForKey("scene"));
    CCMutableArray *items = (CCMutableArray *)(scene -> objectForKey("still"));
    if (items == NULL) return;
    size_t count = items -> count();
    for (int i = 0; i < count; ++i) {
        CCDictionary *item = (CCDictionary *)(items -> getObjectAtIndex(i));
        CCObject* nameObj = item -> objectForKey("name");
        const char* name = (((CCString*) (nameObj)) -> toStdString()).c_str();

the items in the for loop is come from a dictionary in the plist file(‘path’ is the path of the plist file).
The for loop works good for first a few values, but for a certain value such as i=3 in the sample, the var name is not the value in the plist. It’s something ramdom, such as “X(”, “P(”, “((” , or some thing like this.
So I try to skip i=3, but this happens when i=10.

I puts some value in the xml parser in the cocos2dx code. But the values are exactly right. So maybe, the something goes wrong when the parser returns the parsed results to the datastructs ?

It’s really strange…

Does someone have any ideas?

Thank you!


Your code looks well. The key may in the content of your plist file.
Can you please hack HelloWorld to reproduce this bug, then paste the simple project & plist file here? It would help me to find this problem.


As you can see, CCFileUtils::dictionaryWithContentsOfFile() can not parse certain types of xml, like “integer”, “real” and so on.
It is designed for engine to parse certain plist file, such as used for Particle.

So, I think you should parse the xml by yourself.


Hi Minggo,
But these code works with no problem on ipad. And the parsed results which I print from the parser during the parsing process show that the right value have already been parsed out. But I get the wrong value in the end. So it is that possible the issue happens when the parser store the results?

Can this give you some ideas?

And Walzer,
I will try to reproduce it in helloworld!

Thank you very much!


Has this been solved? I’m having the same issue with .plist on android.


No, because I don’t know how to reproduce it.
Could you help us to reproduce it?