class Alternative: NSManagedObject {
@NSManaged var text: String
@NSManaged var isCorrect: Bool
@NSManaged var image: NSData
}
convenience init(text:
You have to call a designated initializer from your convenience initializer. Also, you do not return anything from any initializer.
To fulfill the rules, which are described in Apple's Swift documentation you first need a designated initializer for your subclass, which calls the init() of its superclass, then you can offer a convenience initializer which is only allowed to call a designated initializer from its class declaration.
This would work: (Updated: Taken into account that core data properties marked with @NSManaged are initialized automatically by the runtime. Thanks @Martin R)
init(text: String, isCorrect: Bool, image: NSData, entity: NSEntityDescription, insertIntoManagedObjectContext context: NSManagedObjectContext!) {
super.init(entity: entity, insertIntoManagedObjectContext: context)
}
convenience init(text: String, isCorrect: Bool, entity: NSEntityDescription, insertIntoManagedObjectContext context: NSManagedObjectContext!) {
self.init(text: text, isCorrect: isCorrect, entity: entity, insertIntoManagedObjectContext: context)
}