Building surveys
Now that you have learned about the results of tasks from the previous section, we can modify the Softwareitis
project to incorporate processing of the task results. In the TableViewController.swift
file, let's update the rows
data structure to include the reference for processResultsMethod:
as shown in the following:
//Array of dictionaries. Each dictionary contains [ rowTitle : (didSelectRowMethod, processResultsMethod) ] var rows : [ [String : ( didSelectRowMethod:()->(), processResultsMethod:(ORKTaskResult?)->() )] ] = []
Update the ORKTaskViewControllerDelegate
method taskViewController(taskViewController:, didFinishWithReason:, error:)
in TableViewController
to call processResultsMethod
, as shown in the following:
func taskViewController(taskViewController: ORKTaskViewController, didFinishWithReason reason: ORKTaskViewControllerFinishReason, error: NSError?) { if let indexPath = tappedIndexPath { //1 let rowDict = rows[indexPath.row...