简体   繁体   中英

EXC_BAD_INSTRUCTION when i set UILabel title in Swift 2.0

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)
    }
}

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.

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

您应该编写self.numberLabel.text = "Your text"而不是self.label.text = "Your text"因为您有名为numberLabel而不是label的出口。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM