I just inherited an iOS project which incorporates Apple's ResearchKit (RK).
I have upgraded to the most recent version of RK and also to Swift 3. While I have worked in iOS and RK, I am still not very confident. Anyways, There is a class called SurveyTask
which implements an ORKOrderedTask
from RK.
cannot override 'init' which has been marked unavailable
at the end this function, stepz
already defined, we have:
super.init(identifier: "survey", steps: stepz)
I checked the ORKOrderedTask
class definition, which has an init
function.
I have been reading about initializers but haven't found anything. Using override
or convenience
before the init
in SurveyTask
doesn't change anything. Same error. Any help would be greatly appreciated.
XCode version 8.1.
Here's how you can mimic a parameterless initializer and avoid the unavailable
error:
class MyClass: ParentWithUnavailableInitializer {
init(workaround _: Void = ()) {
// Call a designated initializer
super.init(param: "a very sensible value")
}
}
// At a call site
let obj = MyClass()
Works in Swift 3.2 and Swift 4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With