enum DummyEnum {
case spiderMan
case anotherMan
case tanos
case duppy
var associatedClass: Object.Type {
switch self {
case .spiderMan:
return WebEntity.self
default:
return IronManEntity.self
}
}
}
realm.objects(DummyEnum().spiderMan.associatedClass) // returns crash
realm.objects(WebEntity.self) // done well
Terminating app due to uncaught exception 'RLMException', reason: 'Object type 'RealmSwiftObject' is not managed by the Realm. If using a custom
objectClasses/objectTypesarray in your configuration, addRealmSwiftObjectto the list ofobjectClasses/objectTypes.'
Why the crash is happened and how to resolve it? I need a var for enum to associate Realm objects with enum cases.