title: How to parse into Core Data model from json, where there is an enum with associative values?
body: <p>Model</p>
  <pre><code>struct UserList {
  
      var privacy: Access
      var sharing: Access
  }
  
  enum Access: {
  
      case `private`
      case friendsOnly
      case someFriends(ids: [String])
      case `public`
  } 
  </code></pre>
  <p>CoreData models</p>
  <pre><code>
  @objc(UserListModel)
  public class UserListModel: NSManagedObject {
      @NSManaged public var privacy: AccessModel
      @NSManaged public var sharing: AccessModel
      @NSManaged public var someFriendsPrivacy: SomeFriendsPrivacyModel?
      @NSManaged public var someFriendsSharing: SomeFriendsSharingModel?
  }
  
  @objc(SomeFriendsSharingModel)
  public class SomeFriendsSharingModel: NSManagedObject {
      @NSManaged public var ids: [String]
      @NSManaged public var userList: UserListModel
  }
  
  @objc public enum AccessModel: Int32 {
  
      case `public` = 0
      case friendsOnly = 1
      case someFriends = 2
      case `private` = 3
  
  }
  </code></pre>
  <p>CoreData setup:</p>
  <p><a href="https://i.stack.imgur.com/6U1ff.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6U1ff.png" alt="enter image description here" /></a></p>
  <p>Questions:</p>
  <ol>
  <li>How can I add Codable to UserList to obtain model from json?</li>
  </ol>
  <pre><code>{&quot;privacy&quot;:&quot;friendsOnly&quot;,
  &quot;sharing&quot;:{
      &quot;some_friends&quot;:
            {&quot;ids&quot;:[&quot;id1&quot;,&quot;id2&quot;]}
      }
  }
  </code></pre>
  <ol start="2">
  <li>How do I add Codable to Core Data models? To be able to directly save models from json to Core Data?</li>
  <li>How do I init a UserList model from the Core Data UserListModel?</li>
  </ol>