gpt4 book ai didi

ios - swift 3 : Defining var labels: [UILabel] fails

转载 作者:行者123 更新时间:2023-11-28 08:27:03 25 4
gpt4 key购买 nike

<分区>

我卡在 Swift 3 中的变量声明处。我的代码如下所示:

代码开始

// Letter Buttons
@IBOutlet weak var LetterOneButton: UIButton!
@IBOutlet weak var LetterTwoButton: UIButton!
@IBOutlet weak var LetterThreeButton: UIButton!
@IBOutlet weak var LetterFourButton: UIButton!
@IBOutlet weak var LetterFiveButton: UIButton!

// Word Fields
@IBOutlet weak var WordLetterOne: UILabel!
@IBOutlet weak var WordLetterTwo: UILabel!
@IBOutlet weak var WordLetterThree: UILabel!
@IBOutlet weak var WordLetterFour: UILabel!
@IBOutlet weak var WordLetterFive: UILabel!

// Counter
@IBOutlet weak var CounterLabel: UILabel!

// Skip Button
@IBOutlet weak var SkipButtonLabel: UIButton!

// Define Variables
var index: Int = 0

错误出现在以下行中:

var labels: [UILabel] = [WordLetterOne, WordLetterTwo, WordLetterThree, WordLetterFour, WordLetterFive]

错误消息是“无法在属性初始值设定项中使用实例成员‘WordLetterOne’;属性初始值设定项在‘self’可用之前运行”。之后,声明另一个字符串没有任何问题。

var letters: [String] = ["A", "B", "C", "D", "E"] 

代码结束

非常感谢您的帮助!

编辑:

self.lazy var labels: [UILabel] = [WordLetterOne, WordLetterTwo, WordLetterThree, WordLetterFour, WordLetterFive]

出现错误“一行中的连续声明必须用‘;’分隔”和“实例成员‘WordLetterOne’不能用于‘ViewController’类型”

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com