ResearchKit / ResearchKit/ResearchKit
Saving results for ORKStepViewController Subclass
Nobody has claimed this yet.
- Dominant language
- Objective-C
- Stars
- 5.7k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I've subclassed ORKStepViewController and created UI on storyboard like ORKQuestionStepViewController to add a search option in tableView.
It's working fine. However, couldn't able to get the result object on back and forth.
I've overridden the result property.
override var result: ORKStepResult? {
let orkResult = super.result
guard let identifier = step?.identifier else {return nil}
let choiceResult = ORKChoiceQuestionResult(identifier: identifier)
var choices: [Any] = []
for choice in self.selectedChoices {
choices.append(choice.value)
}
choiceResult.choiceAnswers = choices
orkResult?.results = [choiceResult]
return orkResult
}
But when i go back and come to the view controller, i try to get the result object and it's nil
func taskViewController(_ taskViewController: ORKTaskViewController, viewControllerFor step: ORKStep) -> ORKStepViewController? {
print(step.identifier,"Identifier")
if step.identifier == "newQuestionStep" {
let textChoiceQuestionController = self.storyboard?.instantiateViewController(withIdentifier: "TextChoiceQuestionController") as! TextChoiceQuestionController
textChoiceQuestionController.step = step
return textChoiceQuestionController
}
return nil
}
Ongoing backward When I try to access the result here, I'm able to see my result ob subclass. However, when i click on next to the subclassed VC, I'm getting blank result object in the above delegate for the step identifier.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the custom ORKStepViewController subclass and the taskViewController(_:viewControllerFor:) delegate shown in the issue. Trace how result is read and restored when navigating backward and forward, including the overridden result property and selectedChoices. Done means the subclassed controller retains and returns its ORKStepResult after revisiting the step.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100