I'm trying to implement my own version of convenience init(context moc: NSManagedObjectContext)
, the new convenience initialiser on NSManagedObject in iOS 10. Reason being I need to make it compatible with iOS 9.
I've come up with this:
convenience init(managedObjectContext moc: NSManagedObjectContext) {
let name = "\(self)".components(separatedBy: ".").first ?? ""
guard let entityDescription = NSEntityDescription.entity(forEntityName: name, in: moc) else {
fatalError("Unable to create entity description with \(name)")
}
self.init(entity: entityDescription, insertInto: moc)
}
but it doesn't work because of this error...
'self' used before self.init call
Does anyone know how to get around this error, or achieve the same result in another way.