我正在使用研究套件框架在Swift中开发一个应用程序。用户参加调查时给出的答案将保存在本地数据库中。需要在应用程序中实现功能,以便当用户再次开始调查时,他可以查看先前选择的答案。
我们可以为创建的ORKOrderedTask设置默认选择的值。

以下是使用的代码段:

var steps = [ORKStep]()
let questQuestionStepTitle = "What is your quest?"
let textChoices = [
    ORKTextChoice(text: "Create a ResearchKit App", value: 0),
    ORKTextChoice(text: "Seek the Holy Grail", value: 1),
    ORKTextChoice(text: "Find a shrubbery", value: 2)]
let questAnswerFormat: ORKTextChoiceAnswerFormat =     ORKAnswerFormat.choiceAnswerFormatWithStyle(.SingleChoice, textChoices: textChoices)
let questQuestionStep = ORKQuestionStep(identifier: "TextChoiceQuestionStep", title: questQuestionStepTitle, answer: questAnswerFormat)
steps += [questQuestionStep]
return ORKOrderedTask(identifier: "SurveyTask", steps: steps)


我们可以设置选项的默认选择值吗?

最佳答案

https://github.com/ResearchKit/ResearchKit/issues/689

使用解决方案2。
具体来说,子类是有序类,并覆盖stepAfterStep。

08-19 11:47