8 Comments for this entry

  • Huy

    i created a CCDictionary which has key is a String type and value is a CCInteger* type, but when i use writetofile method, it onl save the key, so i can’t use createWithContentsOfFile to load this file again, can you show me how to solve this problem? tks you!

    here is my code:
    dic = CCDictionary::create();
    CCInteger* num = CCInteger::create(100);
    dic->setObject(num,”first”);
    num = CCInteger::create(200);
    dic->setObject(num,”second”);
    num = CCInteger::create(3000);
    dic->setObject(num,”third”);

    dic->writeToFile(“demo.plist”);

    it saved that:

    first
    second
    third

  • Huy

    first
    second
    third

  • aeonphyxius

    Hi Huy,

    I think CCDictionary can only store CCString objects, as in my code. I mean, you can not use CCInteger or other type. Only CCString.

    For more info, here in this post at the official forums:
    http://www.cocos2d-x.org/forums/6/topics/49323?r=49342

    I hope this helps.

  • aeonphyxius

    The mentioned above behavior only happens in Cocos2d-x below 3.0

    Apparently in the new versions this issue has been fixed.

  • pp

    Im using Xcode 5.1
    cocos2d-x 2.1.5

    I have an exact code like this, but it won’t generate .plist in resource folder

    CCDictionary * m_game_data = new CCDictionary();
    CCString userData =”2″;
    m_game_data->setObject(&userData ,”current_level”);
    m_game_data->writeToFile(“game_data.plist”);

  • pp

    I have exact code like this , but .plist couldn’t be locate anywhere in the project.

    Im using Xcode 5.1
    Cocos2d-x v2.1.5

  • aeonphyxius

    Let me check your code and I will come back to you this evening, but that code should work.

    At least in Windows, where I tested the original code.

  • helios

    Do you have a version of this but using CCArray instead?
    because CCarray uses item0, item1,item2, ..

Leave a Reply