title: Swift: passing value to static class property from UITableViewCell
body: <p>I'm definitely new to Swift and iOS programming so this seems like a fairly easy question/solution and I appreciate any help you can give me.</p>
  
  <p>Basically, what I'm trying to do is: </p>
  
  <ol>
  <li>connect to an api using JSON (complete)</li>
  <li>populate a UITableView using the JSON array that is passed (complete)</li>
  <li>when a UITableViewCell is 'selected' store information about the cell that was selected (complete: in the same class)</li>
  <li>store the information in different ViewController's property (NOT COMPLETE)</li>
  <li>navigate to a new ViewController (complete - I'm using prepareForSegue)</li>
  <li>using the class variable (from number 4.) update a Button's text (NOT COMPLETE because the variable is 'nil')</li>
  </ol>
  
  <p>//the following function is from the first ViewController before the navigation happens</p>
  
  <pre><code>func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
  
      // ... a bunch of other code that isn't important
      // sname is currently holding a String value properly based on which UITableViewCell is selected
  
      let VC2 = ViewController2()
      VC2.player_name = sname
      println(VC2.player_name) // this is printing the proper name which means it is stored correctly in the instance of ViewController2
  }
  
  // This function is also in ViewController1
  override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
      var svc = segue.destinationViewController as ViewController2
  
  }
  
  
  
  class ViewController2: UIViewController {
  
  @IBOutlet weak var btnName: UIButton!
  var player_name: String?
  
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      // By the time we are to update the UIButton's text, the class property 'player_name' is nil again - meaning the name from the previous ViewController wasn't stored
      btnName.setTitle(self.soldier_name, forState: UIControlState.Normal)
  
  }
  </code></pre>
  
  <p>I understand what is probably happening is that when information is stored in ViewController2's class property 'player_name' the information is only stored in an instance of that class which is deallocated when the segue occurs. So, by the time ViewControlle2 is finally reached, what we are looking at is a different instance of the class.</p>
  
  <p>My question is, how do we make a static variable that I can easily change so the value is preserved as I navigate from one ViewController to another???
  Do I have to create a struct in the second class? If so, can someone help me create it?</p>
  
  <p>Thank you for any help you can give me!!!</p>