Assign ViewController to Class or vice versa

195 views Asked by At

i am new to Swift and i started to play around with ResearchKit.
I created a custom class, which is basically the model and i want to connect this with the (also custom ) viewController.

In the API i found this.

To present an active step in your app, it’s likely that you will subclass ORKActiveStep and ORKActiveStepViewController to present custom UI and custom prompts. For example subclasses, see ORKSpatialSpanMemoryStep or ORKFitnessStep. Active steps may also need ORKResult subclasses to record their results if these don’t come purely from recorders.

My problem is : How do i tell/assign the class the viewcontroller ?
There is no "setViewController" method.

1

There are 1 answers

1
jwe On BEST ANSWER

It's the ORKTaskViewController that instantiates the correct step view controller for your step, when it finds the step in the task. It has two ways to do this.

The first is to consult your step's + (Class)stepViewControllerClass class method. If you write a custom step class, override this class method to specify what class of step view controller the task view controller should instantiate by default for that type of step.

The second is to implement the task view controller delegate's -taskViewController:viewControllerForStep: method, and instantiate a step view controller of the correct type when your step is encountered by the task view controller. If you return a non-nil value from this method, it overrides the default outlined above.