Succesfull read data from plist, but now how to change values???

Hi, for my gameData I’m using plist, as its easier to me than xml.

I have successfully read the data but now I have to change values and I have no idea how can I do it.

One of my plist is a dictionary with some strings

std::string levelsFile = CCFileUtils::sharedFileUtils()->fullPathForFilename("gameData.plist"); CCDictionary*dictionary = CCDictionary::createWithContentsOfFileThreadSafe(levelsFile.c_str()); dictionary ->retain(); int characterSelected = dictionary->valueForKey("CharacterSelected")->intValue();

Well, now I want to change that key for other , like

int newCharacterSelected = 2; //something like this is what I want dictionary->setObject(newCharacterSelected, "CharacterSelected"); //But newCharacterSelected is NOT a CCObject

Hope someone can help me

Thanks!

Have a look at the CCUserDefault code.

User Defaults are stored in an xml/plist file so should contain the code to do what you need (if you can follow the code that is.)

plist file just read data, not change. let use ccuserdefaut, anything thing change, call flush().

CCUserDefault only allows 1 level of key/value.
plist allows more complex data to be stored.

I suggest looking at the CCUserDefault code and see if it can be used/modified for your requirements.