How to properly implement ARC compatible and `alloc init` safe Singleton class? [duplicate]
This question already has an answer here: How do I implement an Objective-C singleton that is compatible with ARC? 10 answers I saw thread safe version +(MyClass *)singleton { static dispatch_once_t pred; static MyClass *shared = nil; dispatch_once(&pred, ^{ shared = [[MyClass alloc] init]; }); return shared; } but what would happen if someone just calls [MyClass alloc] init] ? How to make it return same instance as the +(MyClass *)singleton method? Apple recommends the strict singleton implementation (no other living object of the same type is allowed) this way: + (instancetype)singleton {