Group Group Group Group Group Group Group Group Group

How to use RealmEnum?

On Page 63 you describe how to work with Enumerations. I just found the RealmEnum and wonder how to use that. Maybe someone could please explain.

https://realm.io/docs/swift/latest/api/Protocols.html#/s:10RealmSwift0A4EnumP

1 Like

They got some mistakes, working code below:
@objc enum MyEnum: Int, RealmEnum { //deleted the word class
case thing1 = 1
case thing2 = 2
case thing3 = 3
}

class MyModel: Object {
@objc dynamic var enumProperty = MyEnum.thing1 //added the word var
let optionalEnumProperty = RealmOptional()
}

@nbs Thank you for sharing your solution - much appreciated!