title: Using NSNotifications to pass variables between View Controllers
body: <p>I am trying to pass an integer variable between two view controllers using NSNotifications, however despite now having figured out how to detect a notification sent by another view controller, I still haven't figured out how to actually pass a variable within this notification.</p>
  
  <p>This is the code I have in the view controller I am sending the variable from:</p>
  
  <pre><code>func pickerView(pickerView: UIPickerView!, didSelectRow row: Int, inComponent: Int) {
      var colourSelected = row
      println(colourSelected)
      NSNotificationCenter.defaultCenter().postNotificationName("changeColor:", object: colourSelected)
  }
  </code></pre>
  
  <p>And this is the code within the viewDidLoad of the ViewController that I am sending the variable to:</p>
  
  <pre><code>NSNotificationCenter.defaultCenter().addObserver(self, selector: "incomingNotification", name: "changeColor:", object: nil)
  </code></pre>
  
  <p>This is the function that should be receiving the variable:</p>
  
  <pre><code>func incomingNotification() {
  
  if colourSelected == 0 {
  println(0)
  } else if colourSelected == 1 {
  println(1) }
  
  ...
  
  }
  </code></pre>
  
  <p>I am just getting an error saying that colourSelected is an unresolved identifier. </p>
  
  <p>What do I need to change?</p>