【发布时间】:2019-08-07 12:28:49
【问题描述】:
所以我正在处理我的第一个个人项目(包括测验功能),同时参加快速课程。我想弄清楚如何随机化数组。
我找到了一些解释类似内容的视频,但似乎没有什么对我有用。
这是我需要改组的问题库之一的示例。
class ImageQuestionBank {
var list = [ImageQuestion] ()
init () {
let item = ImageQuestion(qtext: "Example Question?", image: "image1", correctAnswer: true)
list.append(item)
list.append(ImageQuestion(qtext: "Example Question?", image: "image2", correctAnswer: false))
list.append(ImageQuestion(qtext: "Example Question?", image: "image3", correctAnswer: true))
}
}
【问题讨论】:
-
为什么 shuffled() 或 shuffle() 不适合你?
标签: arrays swift random shuffle