Re: Getting class when instantiating a singleton

Ben Kennedy

On 30 Aug 2017, at 1:37 pm, Alex Zavatone <zav@...> wrote:

In iOS, when I’m making an Objective-C singleton, in the public method that returns the instanceType, we need to put the class name. Is there a way to do this dynamically instead of entering the class name all the time?
Why is this necessary? Apologies if I'm missing something obvious, but what's wrong with literally using DataSingleton (in your example)?

Even if the method is called on a subclass it should still work as desired because you're calling [self alloc], not [DataSingleton alloc].


Join to automatically receive all group messages.