-1

I am trying to change the text of my label called score with the contents of the currentScore but I keep getting an error:

Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

I also get this error in the console:

fatal error: unexpectedly found nil while unwrapping an Optional value

Anyone ever encountered this? I have no idea what I'm doing wrong.

@IBOutlet weak var score: UILabel!
var currentScore = 0    
let text = "You scored a \(currentScore) out of 3"
score.text = text
Amit
  • 4,837
  • 5
  • 31
  • 46
Carter4502
  • 157
  • 1
  • 11

1 Answers1

2

Connect your IBOutlet to the label. Everything else seems to be correct.

NSAdi
  • 1,243
  • 9
  • 19