A presentation about Apple's ResearchKit framework and how I use it in my App "Depressed?". I held this talk at the CocoaHeads Düsseldorf in January 2016
2. “The ResearchKit™ framework is an
open source software framework
that makes it easy to create apps
for medical research
or for other research projects.”
3. ResearchKit
• open source at https://github.com/researchkit/researchkit
• actively maintained (latest release 14 days old)
• 100% Objective-C
11. Task
• One task consisting of nine steps
public protocol ORKTask : NSObjectProtocol {
/// The unique identifier for this task.
public var identifier: String { get }
/// Returns the step after the specified step, if there is one.
public func stepAfterStep(step: ORKStep?, withResult result: ORKTaskResult) -> ORKStep?
/// Returns the step that precedes the specified step, if there is one.
public func stepBeforeStep(step: ORKStep?, withResult result: ORKTaskResult) -> ORKStep?
}
12. Steps
public class ORKQuestionStep : ORKStep {
public convenience init(identifier: String, title: String?,
answer answerFormat: ORKAnswerFormat?)
}
public class ORKTextChoiceAnswerFormat : ORKAnswerFormat {
public init(style: ORKChoiceAnswerStyle, textChoices: [ORKTextChoice])
}
public class ORKTextChoice : NSObject, NSSecureCoding, NSCopying, NSObjectProtocol {
public convenience init(text: String, value: protocol<NSCoding, NSCopying, NSObjectProtocol>)
}
13. Results all the way down
//MARK: - ORKTaskViewControllerDelegate
func taskViewController(taskViewController: ORKTaskViewController,
didFinishWithReason reason: ORKTaskViewControllerFinishReason, error: NSError?) {
let taskResult = taskViewController.result
}
let stepResults = taskResult.results as! [ORKStepResult]
let firstStepResult = stepResults.first!
// ORKActiveSteps can have multiple results
let questionResult = firstStepResult.firstResult as! ORKChoiceQuestionResult
// multiple choice questions can have multiple results per question
let answer = questionResult.choiceAnswers?.first
// the value of the selected text choice
let value = answer.integerValue