2

I want to change the title of an UILabel, but I receive an EXC_BAD_INSTRUCTION error.
My label was correctly connected to the storyboard and I don't understand why i have an error. Could anybody please point where I am wrong? Thank you for your help.

There is my code :

class ViewController: UIViewController {
    @IBOutlet weak var numberLabel: UILabel!
    override func viewDidLoad() {
        super.viewDidLoad()
        self.numberLabel.text = "qwerty" // Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP,subcode0x0)
    }
}
hennes
  • 9,147
  • 4
  • 43
  • 63
RemyDCF
  • 364
  • 1
  • 4
  • 14

3 Answers3

1

the problem can be localization. Check if you have 2 storyboards created (one base for english and second for other languages). Then check if in both you have the same label. If not it can be a problem.

Marek Staňa
  • 522
  • 7
  • 10
0

Ok, I resolved my problem.
Strangely, if I reinstall Xcode, It's work.
Thanks for your answers.

RemyDCF
  • 364
  • 1
  • 4
  • 14
-1

You should write self.numberLabel.text = "Your text" instead of self.label.text = "Your text" because you have outlet named numberLabel not label .

Tejas Ardeshna
  • 4,343
  • 2
  • 20
  • 39
Adnan Munir
  • 129
  • 7