title: Default Initializer in swift
body: <p>I created a swift class with string optionals (String?) and instantiated the class in a different swift file and got a compile error. When I instantiate the class within the same file, there is no error. Is there something wrong I am doing? I double checked the behaviour and this behaviour is consistent even with the class definition given in the swift documentation:</p>
  
  <pre><code>class ShoppingListItem {
      var name: String?
      var quantity = 1
      var purchased = false
  }
  var item = ShoppingListItem()
  </code></pre>
  
  <p>Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. <a href="https://itun.es/in/jEUH0.l">https://itun.es/in/jEUH0.l</a></p>
  
  <p>If the <code>var item = ShoppingListItem()</code> is done in the <code>appDelegate.swift</code>, from the function <code>application:didFinishLaunchingWithOptions</code> we get the error:</p>
  
  <pre><code>&lt;class&gt; cannot be initialised because it has no accessible initializers
  </code></pre>
  
  <p>OTOH, if we keep the instantiation as soon as the class declaration ends, there is no problem.</p>
  
  <p>Edit: This issue is not a showstopper, the current default initialiser behaviour seems inconsistent or I need to understand it better</p>