首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ResearchKit stepResult for a TextChoiceQuestion

ResearchKit stepResult for a TextChoiceQuestion
EN

Stack Overflow用户
提问于 2015-06-04 16:32:37
回答 1查看 332关注 0票数 0

对于其他问题类型,我正在成功地使用ResearchKit的stepResultForStepIdentifier方法,但无法找到正确的语法预先填充TextChoiceQuestion的结果。

下面是在TextChoice中设置示例ORKCatalog问题结果的失败尝试。对正确的方法有什么建议吗?

代码语言:javascript
复制
func stepResultForStepIdentifier(stepIdentifier: String) -> ORKStepResult? {

    var stepResults = [ORKQuestionResult]()

    if stepIdentifier == "TextChoiceQuestionStep" {

        var questionDefault = ORKChoiceQuestionResult(identifier: stepIdentifier)

        questionDefault.choiceAnswers?.append("choice_2")

        stepResults.append(questionDefault)

    }

    var defaults = ORKStepResult(stepIdentifier: stepIdentifier, results: stepResults)

    return defaults
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-04 17:22:54

choiceAnswers数组是nil吗?当您执行questionDefault.choiceAnswers?.append时,choiceAnswers可能是nil,因此这可能没有任何作用。

相反,做questionDefault.choiceAnswers = ["choice_2"]

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30649369

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档