我的目標是提高我的中獎計數器每次增加數量的用戶環路切塊用我已經嘗試了數6 像這樣:與環路
class ViewController: UIViewController {
@IBOutlet weak var numberDisplayLabel: UILabel!
@IBOutlet weak var jackpotCountLabel: UILabel!
@IBAction func diceRollBtn(_ sender: UIButton) {
var count = 0
let randomNumber = arc4random_uniform((10)+1)
if randomNumber == 6 {
numberDisplayLabel.text = "Jackpot!!! You got \(randomNumber)!"
for count in 0..==6 {
jackpotCountLabel.text = "Jackpot count: \(count)"
}
} else {
numberDisplayLabel.text = "Unlucky! Maybe next time."
}
}
但似乎我不能使用==
作爲操作員來檢查條件。 是否適合這樣的任務?
目前尚不清楚你想要做什麼,請解釋。 – LinusGeffarth
'arc4random_uniform((10)+1)'我試圖產生一個隨機數。如果數字是6,則用戶「贏」。我試圖增加一個計數器,每次用戶切成小塊6,所以用戶可以看到他已經切塊了多少次。6 – JVermeer
我明白了,但那不是你問題所在的地方,對吧?所以解釋你的問題。爲什麼是for循環?增加櫃檯的含義是什麼? – LinusGeffarth