ios - ResearchKit stepResult for a TextChoiceQuestion -
i'm using researchkit's stepresultforstepidentifier
method other question types, can't find correct syntax pre-populate results textchoicequestion.
below unsuccessful attempt @ setting result sample textchoice question in orkcatalog. advice on correct approach?
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 }
is choiceanswers
array nil
? when questiondefault.choiceanswers?.append
, choiceanswers
might nil
, might nothing.
instead questiondefault.choiceanswers = ["choice_2"]
Comments
Post a Comment