title: Singleton Swift Shared [String]
body: <p>I am trying to access the same [String] in two ViewControllers. The first one is setting the array and the second ViewController want to get the array. </p>
  
  <p>Here is the singleton class. </p>
  
  <pre><code>class SavedPostsBox{
  var postNames: [String] = []
  
  class var sharedInstance : SavedPostsBox {
      struct Static {
          static let instance : SavedPostsBox = SavedPostsBox()
      }
      return Static.instance
  }  
  }
  </code></pre>
  
  <p>In the first ViewController I the do this:</p>
  
  <pre><code>SavedPostsBox().postNames = savedPostName
  </code></pre>
  
  <p>And In the second I do this:</p>
  
  <pre><code>savedPostName = SavedPostsBox().postNames
  </code></pre>
  
  <p>The problem is that when I check the sizes in the different classes it is always 0 in the second but not in the first. I tried a lot of different methods and search everywhere but this solutions seems to work for a lot of other people but not for me. </p>