title: Create A Variable for Struct (Swift)
body: <p>I have two structs which look like this:</p>
  
  <pre><code>struct Song {
      var title: String
      var artist: String
  }
  
  var songs: [Song] = [
      Song(title: "Title 1", artist: "Artist 1"),
      Song(title: "Title 2", artist: "Artist 2"),
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>struct Song2 {
          var title: String
          var artist: String
      }
  
      var songs2: [Song] = [
          Song(title: "Title 1", artist: "Artist 1"),
          Song(title: "Title 2", artist: "Artist 2"),
      }
  </code></pre>
  
  <p>I want to create a variable that changes so on diffrent events either the first struct will be referenced, or the second struct will be referenced. Like this.</p>
  
  <pre><code>var structToBeReferenced = //What goes here?
  </code></pre>
  
  <p><strong>ViewController1</strong></p>
  
  <pre><code>override func viewDidLoad() {
          super.viewDidLoad()
  
  structToBeReferenced = songs
  }
  </code></pre>
  
  <p><strong>ViewController2</strong></p>
  
  <pre><code>override func viewDidLoad() {
              super.viewDidLoad()
  
      structToBeReferenced = songs2
      }
  </code></pre>
  
  <p><strong>ViewController3</strong></p>
  
  <pre><code>func theFunction() {
  label.text = structToBeReferenced[thisSong].title
  }
  </code></pre>
  
  <p>Basically, I just want to create a variable that can be changed so that in <strong>ViewController1</strong>, it sets <code>structToBeReferenced</code> to <code>songs</code>. <strong>ViewController2</strong> sets <code>structToBeReferenced</code> to <code>songs2</code>. So that in <strong>ViewController3</strong> whenever <code>theFunction()</code> is called, the right library is referenced. </p>
  
  <p>I hope that made sense. I just need to know what the variable, <code>structToBeReferenced</code>, needs to equal. Thanks for the help!</p>