DOSingleton icon indicating copy to clipboard operation
DOSingleton copied to clipboard

self.isInitialized is set to YES after [super init] in subclasses

Open stel opened this issue 12 years ago • 3 comments

Now you could check if your singleton subclass has already been initialized by checking isInitialized before calling [super init] because DOSingleton will set this property to YES in its init method and your initialization never calls (if you follow convention).

Need some other method to check if singleton has been initialized in subclasses.

stel avatar Oct 15 '13 10:10 stel

+1

vjpr avatar Dec 05 '13 13:12 vjpr

+1

TiborUdvari avatar Mar 27 '14 08:03 TiborUdvari

I've updated the docs.

So for now you could check where the instance is initialized before calling [super init] like this:

- (id)init
{
    if (!self.isInitialized) {
        self = [super init];

        if (self) {
            // Initialize self.
        }
    }

    return self;
}

Still looking for a better solution..

stel avatar May 15 '14 10:05 stel