title: Mantle - Transform String to Enum Value
body: <p>In my <code>User</code> class, I have defined a <code>type</code> property and a <code>UserType</code> enum. The <code>type</code> property is received as a <code>String</code> value in the JSON:</p>
  
  <pre><code>{
      "type" : "Admin"
  }
  </code></pre>
  
  <p>I would like to use <code>Mantle</code> to transform the <code>String</code> value into a <code>UserType</code> enum object and back to a <code>String</code> during serialization and de-serialization, respectively. I have searched through other SO posts and the Mantle documentation but could not get this working properly. Here's my attempt:</p>
  
  <pre><code>enum UserType:String
  {
      case Normal
      case Admin
  }
  
  class User: MTLModel, MTLJSONSerializing
  {
      var type:UserType?
  
      static func JSONKeyPathsByPropertyKey() -&gt; [NSObject : AnyObject]!
      {
          return ["type" : "type"]
      }
  
      static func JSONTransformerForKey(key: String!) -&gt; NSValueTransformer!
      {
          if (key == "type")
          {
              return NSValueTransformer(forName: "UserTypeValueTransformer")
          }
  
          return nil
      }
  }
  
  // Custom Transformer
  class UserTypeValueTransformer : NSValueTransformer
  {
      override func transformedValue(value: AnyObject?) -&gt; UserType
      {
          let theValue:String? = (value as? String)
  
          return ((theValue! == "Admin") ? UserType.Admin : UserType.Normal)
      }
  
      override func reverseTransformedValue(value: AnyObject?) -&gt; AnyObject?
      {
          let theValue:UserType = (value as! UserType)
  
          return ((theValue == UserType.Admin) ? "Admin" : "Normal")
      }
  }
  </code></pre>
  
  <p>In the code above, I made a custom transformer for converting a <code>String</code> to a <code>UserType</code> enum value and back. I have overridden <code>Mantle's</code> <code>JSONTransformerForKey</code> method and specified my custom transformer for the <code>type</code> property in order to perform the conversion. When I try to serialize the JSON into a <code>User</code> object, I receive this error message:</p>
  
  <pre><code>type is not a property of User
  </code></pre>
  
  <p><code>type</code> is clearly a property of the <code>User</code> model, but something is going on that is making <code>Mantle</code> not able to recognize it.</p>
  
  <p>What should I change in my implementation to get the <code>String</code> to enum conversion to work? Thanks in advance for any help!</p>