我正在使用研究工具包框架在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。具体来说,子类ordered class和重写stepAfterStep。