On 7 Jun 2013, at 09:30, "Graham Lee" <gra...@iamleeg.com> wrote:
> Should this be wrapped in if(self == [Singleton class])? I've seen that used > to guard against this +initialize being called multiple times when a subclass > is used that doesn't override the method. Good catch. The answer is... maybe. Typically, singletons don't support subclassing, because the semantics are a bit interesting. It's often better, if you have a singleton that may want extending, to provide some delegate mechanism. Or, alternatively, a way of setting the singleton instance to use. If you expect subclasses, then you need to be a bit more clever to ensure that everything that tries to access the object gets the subclass version. Traditionally, you'd do that by adding a category on the superclass that replaced +sharedInstance with a call to your replacement. If two different libraries try to do this, however, the behaviour is undefined. David -- Sent from my Apple II _______________________________________________ Gnustep-dev mailing list Gnustep-dev@gnu.org https://lists.gnu.org/mailman/listinfo/gnustep-dev