Search code examples
iosxcodeswiftresearchkit

Swift ResearchKit Conditional ORKOrderedTask


I'm currently working on a medical research app with swift based on ResearchKit, which is an objective-c based framework. I'm trying to create a conditional ORKOrderedTask, like the one at: https://gist.github.com/mattio/9126ecc4f08b9f0497d9 Basically, it says that if the answer to the previous question is yes, then display the next question, if not, skip it. I can find the code for it in objective-c but I'm having trouble converting it to swift.


Solution

  • The recently merged ORKNavigableOrderedTask provides that exact functionality by means of using NSPredicates to check against previous or ongoing task results.

    In the RKNavigableTaskExample repository you can find a small self-contained example on how to use the class. The example is written in Objective-C, but it should be easy to call the same APIs from Swift.