cocos2d::UserDefault::synchronize()

Hello,

is there a way to force UserDefault saved data syncronization as we used to do in Objective-C?

[[NSUserDefaults standardUserDefaults] synchronize];

MandarX

I suggest you use SQLite instead of UserDefault :wink:

Use the flush() method.

Thank you for the answer

I suggest you use SQLite

I will, but I am porting some old Objective C projects to C++ and I want to finish as soon as possible.

thank you!

An explanation why to use SQLite instead of UserDefaults/Preferences would be nice. SQLite has more overhead, because you need to maintain all tables and if you don’t use it correct, the file will be deleted and recreated, so everything is lost. In UserDefaults/Preferences nothing will be lost that easy.

For an easy key/value store, the UserDefaults/Preferences are fine IMHO.

2 Likes