title: how to store my own enum as an attribute in CoreData
body: <p>I defined a global enum named MyEnum:</p>
  
  <pre><code>enum MyEnum: Int{
      case year = 100, month, week, day
  }
  </code></pre>
  
  <p>Purpose is to stored this enum as an attribute of my entity(I declare this enum attribute as transformable in xcdatamodel file):</p>
  
  <p><a href="https://i.stack.imgur.com/0QjX9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0QjX9.png" alt="enter image description here"></a></p>
  
  <p>After Creating NSManagedObject Subclass, In +CoreDataProperties.swift, I tried to changed the </p>
  
  <pre><code>@NSManaged public var myEnum: NSObject
  </code></pre>
  
  <p>to </p>
  
  <pre><code>@NSManaged public var myEnum: MyEnum
  </code></pre>
  
  <p>But when performing saveContext(), error still occurred. I just begin to learn and have no way about how to do next</p>
  
  <p>so what extra work should I do to stored my enum as an attribute for my entity? </p>
  
  <p>Please use swift, thanks for any help</p>