Wie soll mein Objective-C Singleton aussehen?

Meiner singleton-accessor-Methode ist in der Regel eine Variante von:

static MyClass *gInstance = NULL;

+ (MyClass *)instance
{
    @synchronized(self)
    {
        if (gInstance == NULL)
            gInstance = [[self alloc] init];
    }

    return(gInstance);
}

Was könnte ich tun um dies zu verbessern?

InformationsquelleAutor der Frage schwa | 2008-09-28

Schreibe einen Kommentar