I have a class that is a singleton. This singleton is instantiated using GCD (via macro that uses a block), and is accessed by other objects via a class method. The problem is I need this singleton to be a delegate of other object.
Where(when) can I set this, I have no access to init, but I need to set this up soon, when the singleton instance is created.
I have a class that is a singleton. This singleton is instantiated using GCD
Share
The normal behavior for a singleton is that, if it needs an internal instance, it creates one the first time it is referenced. (I think that’s what you’re saying but it’s not explicit.) If that’s the case, then it seems that the object that needs to have it as a delegate should simply assign it whenever that object is created. So part of the init of the other object’s creation would be:
self.delegate = [MySingleton sharedInstance];I’m not sure it matters but is there a reason for making it a delegate instead of just using it whenever the object needs to, via something like:
[[MySingleton sharedInstance] doSomething];?