Accessorizer  will generate a singleton for you with overrides and locking


static QVNeuralCenter *sharedInstance = nil;


+ (void) initialize

{

    if (sharedInstance == nil)

        sharedInstance = [[self alloc] init];

}


+ (id) sharedQVNeuralCenter

{

    //Already set by +initialize.

    return sharedInstance;

}


+ (id) allocWithZone: (NSZone *) zone

{

    //Usually already set by +initialize.

    @synchronized(self) {

        if (sharedInstance) {

            //The caller expects to receive a new object, so implicitly retain it

            //to balance out the eventual release message.

            return [sharedInstance retain];

        } else {

            //When not already set, +initialize is our caller.

            //It's creating the shared instance, let this go through.

            return [super allocWithZone: zone];

        }

    }

}


- (id) init

{

    //If sharedInstance is nil, +initialize is our caller, so initialze the instance.

    //If it is not nil, simply return the instance without re-initializing it.

    if (sharedInstance == nil) {

        if ((self = [super init])) {

            //Initialize the instance here.

        }

    }

    return self;

}


- (id) copyWithZone: (NSZone *) zone

{

    return self;

}

- (id) retain

{

    return self;

}

- (unsigned) retainCount

{

    return UINT_MAX; // denotes an object that cannot be released

}

- (void) release

{

    // do nothing

}

- (id) autorelease

{

    return self;

}

Singleton

Based on Peter Hosey’s article “Doing it Wrong”  link

What developers 
are saying ...testimonials.htmltestimonials.htmlshapeimage_1_link_0shapeimage_1_link_1
Videos & TutorialsaccessorizerVideos.htmlaccessorizerVideos.htmlshapeimage_3_link_0
Homeaccessorizer.htmlaccessorizer.htmlshapeimage_4_link_0
© 2002 - 2009 Kevin Callahanhttp://www.kevincallahan.orgshapeimage_5_link_0

KVO

Initialization MethodsinitMethods.htmlinitMethods.htmlshapeimage_6_link_0

Features

Indexed AccessorsindexedAccessors.htmlindexedAccessors.htmlshapeimage_7_link_0
BUYhttp://store.eSellerate.net/s.aspx?s=STR5524388698

only $15