I am using Xcode 8, Swift 3 and Core Data. In all my NSManagedObject classes I include entityName
property. How do I make sure that all classes derived from NSManagedObject have the entityName
property, like below:
public class MUAccount: NSManagedObject {
static let entityName: String = "MUAccount"
}
I tried creating a protocol, and making NSManagedObject confirm to that; however, that didn't work out:
protocol EntityNameAvailable {
static var entityName: String { get }
}
extension NSManagedObject: EntityNameAvailable {
internal static var entityName: String {
return "undefined"
}
}
The above code doesn't work. Is what I am asking possible with Swift? If not, is it possible with any other OOP language, C++, Java?