Using enum as property of Realm model

后端 未结 5 520
感动是毒
感动是毒 2020-12-07 16:34

Is it possible to use an Enum as a property for my model? I currently have a class like this:

class Checkin: RLMObject {
  dynamic var id: Int = 0
  dynamic          


        
5条回答
  •  旧时难觅i
    2020-12-07 17:00

    Diogo T's solution worked before recent updates of RealmSwift. Eventually we now have to conform to RealmEnum protocol to be able to be a managed property of Realm Object.

    @objc enum MyEnum: Int, RealmEnum {
        ...
    }
    

    Or add below in some place:

    extension MyEnum: RealmEnum { }
    

    RealmSwift documentation for it

提交回复
热议问题