gpt4 book ai didi

ios - Swift:识别变量失败

转载 作者:行者123 更新时间:2023-11-28 13:18:32 26 4
gpt4 key购买 nike

我有一个名为 patternRoom 的 IBOutlet,但在我的代码中收到错误。

@IBOutlet private weak var patternRoom: UIImageView!

struct gameBegin {
var playBegin: Bool {
didSet {
if playBegin == true {
println("\(playBegin)")
// for goes in (up to 3) (up to 5) (up to 10)

var swipes = Menu()

if (swipes.no_of_swipes) == 3 {
//blahdeblah
for i in 0 ..< 3 {
patternRoom.image = UIImage(named: "pattern24.png")
//error here 'Game.type does not have a member named patternRoom'
}

}

if (swipes.no_of_swipes) == 5 {
//blahdeblah
}

if (swipes.no_of_swipes) == 10 {
//blahdeblah
}


}
// display picture 1
// check user input == picture
// move ahead or error
// at end display score e.t.c.

}
}
}
}

最佳答案

只需确保以下所有内容都在一个类中(例如您的 View Controller )并且它应该可以正常工作。

@IBOutlet weak var patternRoom: UIImageView!

var playBegin: Bool {
didSet {
if playBegin == true {
println("\(playBegin)")
// for goes in (up to 3) (up to 5) (up to 10)

var swipes = Menu()

if (swipes.no_of_swipes) == 3 {
//blahdeblah
for i in 0 ..< 3 {
patternRoom.image = UIImage(named: "pattern24.png")
//error here 'Game.type does not have a member named patternRoom'
}

}

if (swipes.no_of_swipes) == 5 {
//blahdeblah
}

if (swipes.no_of_swipes) == 10 {
//blahdeblah
}


}
// display picture 1
// check user input == picture
// move ahead or error
// at end display score e.t.c.

}
}

关于ios - Swift:识别变量失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27723482/

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