Singleton

 

Accessorizer generates two types of singleton code.

GCD & NON-GCD

The interface for generating Singleton is available from the main interface, and from the Action Menu and Action Panel utility panels.

Singleton action opens a utility panel

Here you choose your class name and the GCD or NON-GCD

GCD version

+ (id)sharedQVNeuralCenter {

    static dispatch_once_t onceQueue;

    static QVNeuralCenter *qVNeuralCenter = nil;

   

    dispatch_once(&onceQueue, ^{ qVNeuralCenter = [[self alloc] init]; });

    return qVNeuralCenter;

}

NON-GCD version

static QVNeuralCenter *sharedQVNeuralCenterInstance = nil;


+(QVNeuralCenter *) sharedQVNeuralCenter {

    @synchronized(self) {

        if (sharedQVNeuralCenterInstance == nil) {

            sharedQVNeuralCenterInstance = [[self alloc] init];

        }

        return sharedQVNeuralCenterInstance;

    }

}

If you fail to enter a class name, you get place-holders


KVO