【发布时间】:2019-09-22 13:39:44
【问题描述】:
为什么我会得到这个?它是一个隐式展开的可选属性。我不认为我应该得到这个错误。我尝试清理我的构建文件夹并删除派生数据,然后关闭 Xcode。没有任何效果。
var questionsWrap: QuestionsWrapper
func userMadeSelection(
_ responseId: Int,
_ myTheir: Question.Response.Selections.MyTheir,
_ choice: Question.Response.Selections.MyTheir.Choice
) {
guard let id = question.id else { return }
questionsWrap.saveSelection(
questionId: id,
responseID: responseId,
myTheir: myTheir,
choice: choice
) { success in
if !success {
AlertViewController<Any>.alertFailure(
message: "We made a mistake and we weren't able to save your selection."
)
}
}
singleQuestionDataSource.observableQuestion.value = question
print(#line, "userMadeSelectionImportance: \(responseId) \(myTheir) \(choice)")
if choice.changedBetweenPolarAndNeutral(
with: questionsWrap.question.theirInteractionStyle
) {
let presenter = Question.Importance.Presenter(question)
update(presenter?.importance)
questionCell?.importancePresenter = presenter
}
}
方法定义
func saveSelection(
questionId: Int,
responseID: Int,
myTheir: Question.Response.Selections.MyTheir,
choice: Question.Response.Selections.MyTheir.Choice,
context: Context,
successAction: SuccessAction? = nil
) {
guard let questionIndex = questions.index(of: questionId),
let responseIndex = questions[questionIndex].responses.index(of: responseID) else {
successAction?(false)
return
}
questions[questionIndex].responses[responseIndex].set(myTheir, choice, for: context)
let response = questions[questionIndex].responses[responseIndex]
URL.make(
my: response.choice(for: .my, UserDefaults.questionContext),
their: response.choice(for: .their, UserDefaults.questionContext),
forResponseID: responseID,
forQuestionID: questionId,
forContext: UserDefaults.questionContext
).get { jsonDict in
successAction?(jsonDict.success)
}
}
不幸的是,我不知道要提供什么代码来原子地重新创建此问题。
我正在打破常规并发布屏幕截图以证明错误正在显示。
【问题讨论】:
-
请张贴代码,而不是截图。理想情况下是minimal reproducible example。
-
谢谢@MartinR。我这样做了。我不知道我会在几个小时内因为我的遗忘而获得 5 次反对票。你会认为这一点会通过 1 或 2 来传达。无论如何,谢谢你通知我。