I am tasked to migrate an IOS game made with Cocos2d-x into Unity. One of the issues I have is that I don't know where Cocos2d-x writes the user's saved data. The Unity version of the app needs to access that data so that the user doesn't lose their progress.
The Cocos2d-x application saves it's data using something like this: userDefault->setIntegerForKey("coins", 35);
Would anybody know what path/location that user's saved data is stored? Are there ways I can find that out? I've already tried to view it on xcode via Window > Devices and Simulators > Installed Apps but the app isn't listed.
Any help would be appreciated. Thanks.
In cocos2d-x v4:
// write string
[[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithUTF8String:value.c_str()] forKey:[NSString stringWithUTF8String:pKey]];
// read string
NSString *str = [[NSUserDefaults standardUserDefaults] stringForKey:[NSString stringWithUTF8String:pKey]];
// read integer
NSNumber *value = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithUTF8String:pKey]];
Before V 2.1.2 the info was stored in UserDefault.xml
#define XML_FILE_NAME "UserDefault.xml"
#ifdef KEEP_COMPATABILITY
if (! _isFilePathInitialized)
{
// xml file is stored in cache directory before 2.1.2
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
_filePath = [documentsDirectory UTF8String];
_filePath.append("/");
_filePath += XML_FILE_NAME;
_isFilePathInitialized = true;
}
#endif