title: Swift: Storing states in CoreData with enums
body: <p>I want to store an enum state for a managed object within CoreData</p>
  
  <pre><code>enum ObjStatus: Int16 {
      case State1 = 0
      case State2 = 1
      case State3 = 3
  }
  
  class StateFullManagedObject: NSManagedObject {
      @NSManaged var state: Int16
  }
  </code></pre>
  
  <p>The last step would be converting the state var of StateFullManagedObject to ObjStatus for direct comparison, which isn't working for me. For example, I can't use the == operator between and Int16 and the Int16 enum. The compile time error I get is </p>
  
  <blockquote>
    <p>Int16 is not convertible to 'MirrorDisposition'</p>
  </blockquote>
  
  <p>.  See the conditional below:</p>
  
  <pre><code>var obj: StateFullManagedObject = // get the object
  
  if (obj.state == ObjStatus.State1) { // Int16 is not convertible to 'MirrorDisposition'
  
  }
  </code></pre>
  
  <p>How can I compare/assign between an Int16 and an enum?</p>