I get the compiler message: must call a designated initializer of the superclass NSManagedObject (in swift)
//-------------------------------------
class abc : NSManagedObject {
init(x:String, y:String){
super.init() // <<====== here!!
self.x = x
self.y = y
}
}
//-------------------------------------
the var(s) are declared in the extension xxxx { .... } How to initialize this superclass?
The designated initialiser is
init(entity entity: NSEntityDescription, insertIntoManagedObjectContext context: NSManagedObjectContext?)
and that is the super init
function you must call.
In Xcode Version 12.5 (12E262) I would do it like this this:
class abc : NSManagedObject {
init(x:String, y:String , entity: NSEntityDescription, context: NSManagedObjectContext?){
super.init(entity: entity, insertInto: context)
self.x = x
self.y = y
}
}
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