diff --git a/mogenerator.m b/mogenerator.m index 4a6b819e..4c6ab607 100644 --- a/mogenerator.m +++ b/mogenerator.m @@ -151,6 +151,12 @@ - (BOOL)hasCustomSuperentity { } } +- (BOOL)hasCustomSuperclass { + // For Swift, where "override" is needed when both the entity and its superentity have custom classes. + BOOL result = [self hasCustomClass] && [self hasCustomSuperentity] && [[self superentity] hasCustomClass]; + return result; +} + - (BOOL)hasAdditionalHeaderFile { return [[[self userInfo] allKeys] containsObject:kAdditionalHeaderFileNameKey]; } diff --git a/templates/machine.swift.motemplate b/templates/machine.swift.motemplate index 4189bc4d..409eea6c 100644 --- a/templates/machine.swift.motemplate +++ b/templates/machine.swift.motemplate @@ -34,11 +34,11 @@ class _<$managedObjectClassName$>: <$customSuperentity$> { // MARK: - Class methods - <$if hasCustomSuperentity$>override <$endif$>public class func entityName () -> String { + <$if hasCustomSuperclass$>override <$endif$>public class func entityName () -> String { return "<$name$>" } - <$if hasCustomSuperentity$>override <$endif$>public class func entity(managedObjectContext: NSManagedObjectContext!) -> NSEntityDescription! { + <$if hasCustomSuperclass$>override <$endif$>public class func entity(managedObjectContext: NSManagedObjectContext!) -> NSEntityDescription! { return NSEntityDescription.entityForName(self.entityName(), inManagedObjectContext: managedObjectContext); }