title: Swift initializer is inaccessible due to private protection level
body: <p>I'm trying to create a singleton in Swift but I'm getting this error:</p>
  
  <blockquote>
    <p>initializer is inaccessible due to private protection level</p>
  </blockquote>
  
  <p>Here is my code (singleton class)</p>
  
  <pre><code>class mySingleton{
  
      private init() {    }
      static let sharedInstance = mySingleton()
      var numbers = 0
  
      func incrementNumberValue() {
          numbers += 1
      }
  }
  </code></pre>
  
  <p>Here is where I'm calling the singleton:</p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
      let single = mySingleton().sharedInstance
  }
  </code></pre>
  
  <p>Here is the error:</p>
  
  <p><a href="https://i.stack.imgur.com/W407o.png" rel="noreferrer"><img src="https://i.stack.imgur.com/W407o.png" alt="enter image description here"></a>
  Any of you know why or how I can fix this error?</p>