我GKRandomSource
在一个结构中使用在视图中返回一个随机的鼓舞人心的报价。有没有办法返回该随机数并省略先前的条目?这样用户就不会连续两次收到相同的报价。
let inspiration = [
"You are looking rather nice today, as always.",
"Hello gorgeous!",
"You rock, don't ever change!",
"Your hair is looking on fleek today!",
"That smile.",
"Somebody woke up on the right side of bed!"]
func getRandomInspiration() -> String {
let randomNumber = GKRandomSource.sharedRandom().nextIntWithUpperBound(inspiration.count)
return inspiration[randomNumber]
}