title: iOS swift Singleton init method
body: <p>I'm writing a singleton class to access socket by adopting <a href="https://github.com/pkyeck/socket.IO-objc" rel="nofollow">socket.IO-objc</a>, here's what I did so far:</p>
  
  <pre><code>class Singleton_SocketManager: NSObject, SocketIODelegate {
      var isSocketConnected: Bool = false
      var socket: SocketIO
  
      override init() {
          super.init()
      }
  
      class var sharedInstance: Singleton_SocketManager {
          struct Static {
              static var onceToken: dispatch_once_t = 0
              static var instance: Singleton_SocketManager? = nil
          }
          dispatch_once(&amp;Static.onceToken) {
              Static.instance = Singleton_SocketManager()
          }
          return Static.instance!
      }
  }
  </code></pre>
  
  <p>Yet the compiler complains:</p>
  
  <pre><code>Property 'self.socket' not initialized at super.init call
  </code></pre>
  
  <p>How should I write my init method here to make the compilation error go away?</p>
  
  <p>By the way, I transitioned the code above from objective-c, in obj-c, the SocketIO is initialized like so:</p>
  
  <pre><code>    self.socket = [[SocketIO alloc] initWithDelegate:self];
  </code></pre>
  
  <p>And If I put the init method this way:</p>
  
  <pre><code>    override init() {
      self.socket = SocketIO(delegate: self)
      super.init()
  }
  </code></pre>
  
  <p>It complains:</p>
  
  <pre><code>self used before super.init call
  </code></pre>