title: How to make my singleton class extendable?
body: <p>We have a singleton class in one of our static libraries. It is a singleton because we want to be able to "remember" its state at all times. In essence it is a User management singleton.</p>
  
  <p>It has a property <code>User *user</code> and it has methods such as <code>- (void)authenticateUser</code>.</p>
  
  <p>We want to deliver this to a client who will want to create their own <code>- (void)authenticateUser</code> method. To do this I envisioned they would extend the <code>UserManager</code> class and just override the method.</p>
  
  <p>However as it is a singleton it has methods like: <code>- (id)sharedInstance</code> and a custom <code>alloc</code> method. They all look like this:</p>
  
  <pre><code>static UserManager *_sharedInstance = nil;
  
  + (id)sharedInstance {
      @synchronized([UserManager class]) {
          if(!_sharedInstance){
              id temp = [[self alloc] init];
              [temp class];
          }
          return _sharedInstance;
      }
      return nil;
  }
  
  + (id)alloc {
      @synchronized([UserManager class]) {
          NSAssert(_sharedInstance == nil, @"Attempted to allocate a second instance of a singleton");
          _sharedInstance = [super alloc];
          return _sharedInstance;
      }
      return nil;
  }
  </code></pre>
  
  <p>So given this, is it possible to subclass and extend this <code>UserManager</code> class? Can I create a <code>ChildUserManager</code> which overrides a function? Or will I have to rewrite these singleton methods to deal with the "new" child class?</p>
  
  <p>Is there any way that I can modify these methods to make it so that 3rd parties can easily extend this class?</p>
  
  <p>Thanks</p>