gpt4 book ai didi

ios - 未使用结构

转载 作者:行者123 更新时间:2023-11-30 13:15:26 25 4
gpt4 key购买 nike

我的应用程序包含 50 多个问题。每个问题都有:

  1. 一个问题,
  2. 正确答案
  3. 三个错误答案
  4. 图像名称

所以我用这些属性创建了一个结构。屏幕上一次只会显示一个问题,因此我开始设置我的问题,如下所示:

let question1 = structName... (pass question info)
let question2 = structName... (pass question 2 info)

但是,这会收到“变量未使用”警告。我做错了什么以及我该怎么做?

最佳答案

我无法将错误的答案合并到一个数组中,但我可以通过将所有结构存储在一个数组中来使用此设计模式,这确保了它们全部被使用:

    //Question one
let questionPackage = QuestionInfo(
questionNum: 1,
questionType: "Single",
answer: "Correct answer here",
wrongAnswer_1: "This is wrong",
wrongAnswer_2: "So is this",
wrongAnswer_3: "So is not right"
)

//Question two
let questionPackage2 = QuestionInfo(
questionNum: 1,
questionType: "Single",
answer: "Correct answer here",
wrongAnswer_1: "This is wrong",
wrongAnswer_2: "So is this",
wrongAnswer_3: "So is not right"
)

let questionArray = [questionPackage,questionPackage2]
let loadQuestion = questionArray[questionNum]

关于ios - 未使用结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38285406/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com