我有一个字符串数组。
var questions = ["is it green?", "is it square?", "Where can you find it"]
我需要访问它的值。 SKLabelNode显示它的随机值。我需要检查是否正确的值来给出正确的答案。但是,如果我试试这个:
if questions[0] {
print("0")
}
它表示“不能下标String类型的值”。我还尝试命名每个值,例如
let first = questions[0]
等等。怎么做正确的方法?
答案 0 :(得分:0)
let indexOfAnswer = questions.indexOf(randomValue)
print(indexOfAnswer)