title: Bar button Item enabling problems in Swift
body: <p>All, </p>
  
  <p>In ViewDidLoad , I have set : </p>
  
  <pre><code>BarButtonPAY.enabled = false
  </code></pre>
  
  <p>and that disables the bar button item and it is not selectable, thats fine. </p>
  
  <p>I have an computed property on the View Controller, which enables the button with enable = true. </p>
  
  <p>I am getting the error 'found nil in optional value' and I noticed that BarButtonItem is an optional. When I put the ? at the end of the variable it still does not enable. any ideas ? </p>
  
  <pre><code>class ViewController: UIViewController {
  
      @IBOutlet weak var BarButtonPAY: UIBarButtonItem!
  
      var PayButton : Int {
          didSet {
                  println("Barracuda")
                      BarButtonPAY?.enabled = true
          }
      }
  </code></pre>
  
  <p>I have set the computed property differently now in the view controller - like so (removed the var from init). </p>
  
  <pre><code>@IBOutlet weak var BarButtonPAY: UIBarButtonItem!
  
      var PayButton : Int? {
          didSet {
              println("Barracuda")
              BarButtonPAY?.enabled = true
          }
      }
  
  
      required init(coder aDecoder: NSCoder) {
        //  self.PayButton = 0
          super.init(coder: aDecoder)
      }
  
      init() {
         // self.PayButton = 0
          super.init(nibName: nil, bundle: nil)
  
      }
  </code></pre>
  
  <p>When the button is pressed on the tableview cell. To select a product, and highlight the pay button as a BarButtonItem : </p>
  
  <pre><code>@IBAction func SelectedButton(sender: UIButton) {
  
  
      // Set the colours and then highlight 'Next' on
      sender.backgroundColor = UIColor.blueColor()
      sender.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal)
      sender.setTitle("Ordered", forState: UIControlState.Normal)
  
      let test = ViewController()
      test.PayButton = 2
  
  }
  </code></pre>