Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

251
Vistas
Path / Location of Cocos2d-x UserDefault data in IOS?

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.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

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
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda