Active tasks
Abstractly, the built-in active tasks consist of an instruction step (ORKInstructionStep
), a get ready countdown step (ORKCountdownStep
), task-specific step or steps, followed by a conclusion step (ORKCompletionStep
). These tasks are instantiated following the same generic creation pattern employed by ResearchKit:
// 1 let task = ORKOrderedTask.fitnessCheckTaskWithIdentifier("FitnessTask", intendedUseDescription: "Blah, blah",walkDuration: 30.0,restDuration: 15.0,options: .None) // 2 let taskViewController = ORKTaskViewController(task: task, taskRunUUID: nil) // 3 taskViewController.delegate = self // 4 let defaultFileManager = NSFileManager.defaultManager() let documentDirectoryURL = defaultFileManager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask) taskViewController.outputDirectory = documentDirectoryURL.first! // 5 presentViewController(taskViewController, animated: true, completion: nil)
The explanation of the above...