title: Passing value from struct array with segue : index out of range
body: <p>Hopefully this will be the last question i need to ask!
  I have been looking into this for 48 hours now and i still cannot find answers.</p>
  
  <p>Here is the code i am using:</p>
  
  <p>DataSource.swift:</p>
  
  <pre><code>struct Game {
      var name : String
      var cheats : [Cheat]
  }
  struct Cheat {
      var name : String
      var code : String
      var desc : String
  }
  </code></pre>
  
  <p>GameListViewController.swift</p>
  
  <pre><code>import Foundation
  import UIKit
  
  class GameListViewController: UITableViewController {
  
      var gamesArray = [Game]()
      var cheatsArray = [Cheat]()
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          gamesArray = [Game(name: "Game1", cheats: [Cheat(name: "cheat1", code: "code1", desc: "desc1")])]
  
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
      }
  
      override func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
          return 1
      }
  
      override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return gamesArray.count
      }
  
      override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
          let cell = self.tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell!
          cell.textLabel?.text = gamesArray[indexPath.row].name
          return cell
      }
  
      override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
          let indexPath : NSIndexPath = self.tableView.indexPathForSelectedRow!
          let DestViewController = segue.destinationViewController as! CheatListViewController
  
          var DataPass : Cheat
          DataPass = cheatsArray[indexPath.row]
          DestViewController.cheatnameArray = DataPass.name
  
          var DataPass2 : Cheat
          DataPass2 = cheatsArray[indexPath.row]
          DestViewController.cheatcodeArray = DataPass2.code
  
          var DataPass3 : Cheat
          DataPass3 = cheatsArray[indexPath.row]
          DestViewController.cheatdescArray = DataPass3.desc
      }
  
  }
  </code></pre>
  
  <p>CheatListViewController.swift</p>
  
  <pre><code>class CheatListViewController: UITableViewController {
  
      var cheatcodeArray = String()
      var cheatnameArray = String()
      var cheatdescArray = String()
  
      override func viewDidLoad() {
          super.viewDidLoad()
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
      }
  
  }
  </code></pre>
  
  <p>When i select "Game 1" from gamesArray i instantly receive an index out of range error from the first instance of "DataPass".
  I have structured my datasource in this way so that i do not have to edit arrays separately and keep my objects neat and tidy.</p>
  
  <p>If someone could point me in the right direction i would be forever grateful !</p>
  
  <p>Kind regards
  Rory</p>