Swift adds great new features to enums.

      However, it is not possible to directly persist enums to a Realm, because of the libraries use of the dynamic keyword (Obj-C only).
      At the moment I am solving such issues like the following, but this should really be handled by the RLMObject behind the scenes.

      Open for other suggestions ✨

      enum State: String {
          case Open = "open"
          case Closed = "closed"
      }
      
      class Foo: RLMObject {
          dynamic var stateRaw = ""
          var state: State {
              get {
                  if let a = State.fromRaw(stateRaw) {
                      return a
                  }
                  return .Closed
              }
          }
      }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: