【发布时间】:2015-05-11 03:41:50
【问题描述】:
我知道有一些使用 shuffle 或类似的解决方案,但我不知道是否可以在我的代码中应用它们。你能帮我么?如何让问题不再重复?
func RandomQuestions(){
var RandomNumber = arc4random() % 28
RandomNumber += 1
switch(RandomNumber){
case 1:
QuestionLabel.text = "Who is the Numer One Best DJ According to DJ Mag 2014?"
Button1.setTitle("Tiësto", forState: UIControlState.Normal)
Button2.setTitle("Avicii", forState: UIControlState.Normal)
Button3.setTitle("Hardwell", forState: UIControlState.Normal)
Button4.setTitle("Dimitri Vegas & Like Mike", forState: UIControlState.Normal)
CorrectAnwser = "3"
break
case 2:
QuestionLabel.text = "Who is the Only DJ that played in an Olimpic Games?"
Button1.setTitle("Avicii", forState: UIControlState.Normal)
Button2.setTitle("Tiësto", forState: UIControlState.Normal)
Button3.setTitle("Armin Van Buuren", forState: UIControlState.Normal)
Button4.setTitle("Calvin Harris", forState: UIControlState.Normal)
CorrectAnwser = "2"
break
}
/* ...more questions...* /
}
【问题讨论】:
-
您的问题到底是什么?
-
如果有代码,这样问题就不会重复(感谢提问)@JacobsonTalom
-
由于语法原因,我删除了我的答案 - 感谢@fogmeister 的精彩课程
-
有人可以停止投票此页面上的所有内容吗?至少解释一下为什么?!对拒绝投票按钮感到满意绝对没有什么好处。尤其是正确答案。
标签: xcode swift random arc4random