Forums » C++ Framework » issue when getting value from plist file »
| Yang Huang | issue when getting value from plist file | ||||
|---|---|---|---|---|---|
|
Added by Yang Huang almost 2 years ago
Hi all,
CCDictionary<std::string, CCObject*> *dict = CCFileUtils::dictionaryWithContentsOfFile(path);
CCDictionary<std::string, CCObject*> *scene = (CCDictionary<std::string, CCObject*>* )(dict -> objectForKey("scene"));
CCMutableArray<CCObject*> *items = (CCMutableArray<CCObject*> *)(scene -> objectForKey("still"));
if (items == NULL) return;
size_t count = items -> count();
for (int i = 0; i < count; ++i) {
CCDictionary<std::string, CCObject*> *item = (CCDictionary<std::string, CCObject*> *)(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). 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! |
||||
| Zhe Wang | RE: issue when getting value from plist file | ||||
|
Added by Zhe Wang almost 2 years ago
Your code looks well. The key may in the content of your plist file. Enjoy Coding, Enjoy Life. |
||||
| Minggo Zhang | RE: issue when getting value from plist file | ||||
|
Added by Minggo Zhang almost 2 years ago
As you can see, CCFileUtils::dictionaryWithContentsOfFile() can not parse certain types of xml, like "integer", "real" and so on. So, I think you should parse the xml by yourself. |
||||
| Yang Huang | RE: issue when getting value from plist file | ||||
|
Added by Yang Huang almost 2 years ago
Hi Minggo, Can this give you some ideas? And Walzer, Thank you very much! |
||||
| matthew lebo | RE: issue when getting value from plist file | ||||
|
Added by matthew lebo over 1 year ago
Has this been solved? I'm having the same issue with .plist on android. |
||||
| Minggo Zhang | RE: issue when getting value from plist file | ||||
|
Added by Minggo Zhang over 1 year ago
No, because I don't know how to reproduce it. |
(1-5/5)