From af525e85148bfe37546c199bda9b40bb71713bd5 Mon Sep 17 00:00:00 2001 From: Ryan Mannion Date: Fri, 17 Jan 2020 17:26:00 -0800 Subject: [PATCH] Reproduce Mani's mogenerator template changes --- templates/machine.swift.motemplate | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/templates/machine.swift.motemplate b/templates/machine.swift.motemplate index 891d7c7b..bcd90b9e 100644 --- a/templates/machine.swift.motemplate +++ b/templates/machine.swift.motemplate @@ -8,12 +8,15 @@ import CoreData extension <$managedObjectClassName$> { - <$if (hasCustomSuperclass || (hasCustomSuperentity && TemplateVar.overrideBaseClass))$>override <$endif$>@objc public class var entityName: String { + // MARK: - Class methods + + <$if (hasCustomSuperclass || (hasCustomSuperentity && TemplateVar.overrideBaseClass))$>override <$endif$>open class func entityName () -> String { return "<$name$>" } - <$if (hasCustomSuperclass || (hasCustomSuperentity && TemplateVar.overrideBaseClass))$>override <$endif$>public class func entity(managedObjectContext: NSManagedObjectContext) -> NSEntityDescription? { - return NSEntityDescription.entity(forEntityName: entityName, in: managedObjectContext) + <$if (hasCustomSuperclass || (hasCustomSuperentity && TemplateVar.overrideBaseClass))$>override <$endif$>@nonobjc + open class func fetchRequest() -> NSFetchRequest<<$name$>> { + return NSFetchRequest(entityName: self.entityName()) } <$if noninheritedAttributes.@count > 0$>