Problem with Singleton in ios

Please show me how to implement a Singleton in cocos2d-x 2.2.2.
I want to create a singleton class like “SceneManager” to manage all resources( sprites ). Each sprite is created with image name, position…which are read from a Plist file.

Plist file:
Obj0

Image
background.png
Position
0,0

I use CCDictionary to read Plist file.

The crazy thing is when I run win32 project, it works fine, and when I run ios project, it doesn’t show anything, just shows a black screen. Debugging shows that it did not read Plist file successfully, nothing is read.

It’s hard to answer without the actual code, but let me guess:

Maybe it’s a problem with static class members - their initialization time is implementation defined? http://www.parashift.com/c++-faq/static-init-order.html

The “proper” way of creating a singleton in C++ is to hide the class’ constructors, like so:

// MySingleton.h
class MySingleton {
public:
    // Destructor
    ~MySingleton();

    // Singleton access
    static MySingleton & getInstance();

private:
    // Default constructor
    MySingleton();

    // Copy constructor
    MySingleton( MySingleton const & );

    // Assignment operator
    void operator=( MySingleton const & );
};
// MySingleton.cpp
MySingleton::MySingleton() { }

MySingleton::~MySingleton() { }

MySingleton & MySingleton::getInstance() {
    static MySingleton instance;
    return instance;
}

Not seeing any code makes it hard to give a correct answer, though.