this is a follow up question to this : Assign ViewController to Class or vice versa
So i have a ViewController called SwipeStepViewController, it subclasses from ORKActiveStepViewController. In the SwipeStep class i try to override the default ViewController with my custom SwipeStepViewController
.
I tried to override the +stepViewControllerClass
method and return my Custom Viewcontroller inside the SwipeStep class:
import ResearchKit
class SwipeStep:ORKActiveStep{
override func stepViewControllerClass(){
return SwipeStepViewController.self
}
}
but this does not work at all. I use researchkit, but i guess it is a general swift question.
I don't have any experience with ResearchKit, but after taking a look at the Objective-C code I believe your method should be:
override class func stepViewControllerClass() -> AnyClass {
return SwipeStepViewController.self
}
To explain why you're getting the errors:
Method does not override any method from its superclass.
and
'SwipeStepViewController.Type' is not convertible to '()'
take a look at the class method (indicated by the +
) you're supposedly overriding:
+ (Class)stepViewControllerClass {
return [ORKFormStepViewController class];
}
Compare this with your method:
override func stepViewControllerClass(){
return SwipeStepViewController.self
}
which is neither a class method, nor returns a class and it's clear where the errors are coming from.