In Objective-C I can do this:
@interface MyManagedObjectSuperClass : NSManagedObject
+(NSString*)entityName;
@end
@implementation
+(NSString*)entityName
{
return NSStringFromClass([self class])
}
@end
With this base class, all my other NSManagedObjects can inherit from MyManagedObjectSuperClass. I can get the entity name by calling +entityName, since there is polymorphism, in subclasses, NSStringFromClass([self class]) returns the class name of subclass.
So my question is, can I do this in Swift?