0

I am trying to make a very simple card game application. While I was building it, I reached to a point where I needed to change the text on a Label. Xcode throws an unexpected error:

Thread1: EXC_BADINSTRUCTION (code=EXC_1386_INVOP, subcode=0x0)

Is there a way to solve that issue?

Thanks for the advice

Code:

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var firstCardImageView: UIImageView!
    @IBOutlet weak var secondCardImageView: UIImageView!
    @IBOutlet weak var playRoundButton: UIButton!
    @IBOutlet weak var backgroundImageView: UIImageView!
    @IBOutlet weak var Player1CardsLabel: UILabel!
    @IBOutlet weak var Player2CardsLabel: UILabel!
    var player1Cards:[Int] = []
    var player2Cards:[Int] = []
    var cardIndex1 = 0
    var cardIndex2 = 0

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        self.playRoundButton.setTitle("Play", forState: UIControlState.Normal)
        print(self.playRoundButton.currentTitle)
        self.secondCardImageView.image = UIImage(named: "back")
        Player1CardsLabel.text = "2"  //Here Xcode throws the  above error
    }
GeorGios
  • 91
  • 3
  • 16
  • 1
    Check the `Player1CardsLabel` IB outlet is connected – Hamish Jul 01 '16 at 16:21
  • 1
    Thank you @originaluser2! I just needed to hold ctrl and right click to connect the Label to Player1CardsLabel in order to allow the change. – GeorGios Jul 01 '16 at 16:23

0 Answers0