So, I am very new to XCode and Swift. I am having trouble changing the title text on a UIButton, and I keep getting the error
fatal error: unexpectedly found nil while unwrapping an Optional value
This is my code :
//
// ViewController.swift
// mtgHealthTracker
//
// Created by Reagan McFarland on 5/1/16.
// Copyright © 2016 Reagan McFarland. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
//Mark : Properties
@IBOutlet weak var btnPlayer1Health: UIButton!
@IBOutlet weak var btnPlayer4Health: UIButton!
@IBOutlet weak var btnPlayer3Health: UIButton!
@IBOutlet weak var btnPlayer2Health: UIButton!
@IBOutlet weak var lblCurrWinner: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//Mark Actions
@IBAction func btnPlayer1HealthChanged(sender: UIButton, forEvent event: UIEvent) {
btnPlayer1Health.setTitle("Hello World", forState: UIControlState.Normal)
}
@IBAction func btnPlayer2HealthChanged(sender: UIButton, forEvent event: UIEvent) {
}
Help is greatly appreciated! Thanks :)