title: Converting Swift 3 code without use of dispatch_once_t
body: <p>Prior to migrating to Swift 3, I had the following code:</p>
  
  <pre><code>//Set up singleton object for the tracker
  class func setup(tid: String) -&gt; WatchGATracker {
      struct Static {
          static var onceToken: dispatch_once_t = 0
      }
      dispatch_once(&amp;Static.onceToken) {
          _analyticsTracker = WatchGATracker(tid: tid)
      }
      return _analyticsTracker
  }
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>'dispatch_once_t' is unavailable in Swift: Use lazily initialized globals instead
  </code></pre>
  
  <p>Apparently, the conversion tool converted the code to this:</p>
  
  <pre><code> class func setup(_ tid: String) -&gt; WatchGATracker {
      struct Static {
          static var onceToken: Int = 0
      }
      _ = WatchGATracker.__once
      return _analyticsTracker
  }
  </code></pre>
  
  <p>And at the top of my class, it added this:</p>
  
  <pre><code>private static var __once: () = {
          _analyticsTracker = WatchGATracker(tid: tid)
  }()
  </code></pre>
  
  <p>But I still get an error:</p>
  
  <pre><code>Instance member 'tid' cannot be used on type 'WatchGATracker'
  </code></pre>
  
  <p>tid is declared as:</p>
  
  <pre><code>fileprivate var tid: String
  </code></pre>
  
  <p>It used to be declared as:</p>
  
  <pre><code>private var tid: String
  </code></pre>
  
  <p>I cannot seem to figure out how to fix my code, does anyone have any suggestions?</p>