Re: Getting class when instantiating a singleton


Jon Gotow
 

Couldn't you just make it:

static id instance;

instead?

- Jon

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

I did this a few years ago but can’t find my sample and figured I’d ask the brain trust here.

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?

For example, where I have “DataSingleton" below, can’t we get the name of class instance without having to enter the class name? This would be so much nicer and time saving.

Join cocoa@apple-dev.groups.io to automatically receive all group messages.