persist dictionary data

Hi all,
to persist data of type nsdictionary, we can call writeToFile to save it as a plist file in obj-c.
What’s the best way to do it in cocos2d-x. any c++ library?
thanks in advance.:slight_smile:

cocos2d-x wrapped CCUserDefault to persist data in xml format, it’s multi-platform.
http://github.com/cocos2d/cocos2d-x/blob/master/cocos2dx/include/CCUserDefault.h
You can find the sample code in the tests
https://github.com/cocos2d/cocos2d-x/tree/master/tests/tests/UserDefaultTest

I find a problem that this class isn’t well documented and can not seen in the doxygen output.
Issue #622 is created for this document job.

1 Like

thanks Walzer :slight_smile:
but it seems that CCUserDefault can only handle simple data type like int, float, string etc, not dictionary.
I decide to isolate persistence and to use the native implementation in iOS/android…
any suggestion? :0

SQLite may fit your requirement, since it’s integrated in both ios & android sdk.

thanks Walzer :slight_smile: