简体   繁体   English

快速错误(EXC_BAD_INSTRUCTION)

[英]Swift Error (EXC_BAD_INSTRUCTION)

I have one error that I can't fix. 我有一个无法修复的错误。 I am new to using Swift so I am a little lost here. 我是使用Swift的新手,所以我在这里有些迷路。 在此处输入图片说明

Basic Swift

super.viewDidLoad() should be called before you start writing code in the function. 在开始在函数中编写代码之前,应调用super.viewDidLoad() Basically, the super function is calling the behind-the-scenes viewDidLoad function before you run your own code. 基本上,超级函数在运行您自己的代码之前会调用幕后viewDidLoad函数。

override func viewDidLoad() {
    super.viewDidLoad()
    TimeLabel.text = "\(counter)"
}

Also, notice the way that I wrote the string. 另外,请注意我编写字符串的方式。 This is called string interpolation and is the correct way to place variables in a string. 这称为字符串插值,是将变量放置在字符串中的正确方法。 For example: "The value is (counter * 2/3)" 例如:“值是(计数器* 2/3)”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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