{"action":"created","issue":{"url":"https://api.github.com/repos/JohnSundell/Unbox/issues/32","repository_url":"https://api.github.com/repos/JohnSundell/Unbox","labels_url":"https://api.github.com/repos/JohnSundell/Unbox/issues/32/labels{/name}","comments_url":"https://api.github.com/repos/JohnSundell/Unbox/issues/32/comments","events_url":"https://api.github.com/repos/JohnSundell/Unbox/issues/32/events","html_url":"https://github.com/JohnSundell/Unbox/issues/32","id":136016915,"number":32,"title":"Enum fallback not working (Unbox 1.3)","user":{"login":"timlentonBCGDV","id":16870288,"avatar_url":"https://avatars.githubusercontent.com/u/16870288?v=3","gravatar_id":"","url":"https://api.github.com/users/timlentonBCGDV","html_url":"https://github.com/timlentonBCGDV","followers_url":"https://api.github.com/users/timlentonBCGDV/followers","following_url":"https://api.github.com/users/timlentonBCGDV/following{/other_user}","gists_url":"https://api.github.com/users/timlentonBCGDV/gists{/gist_id}","starred_url":"https://api.github.com/users/timlentonBCGDV/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timlentonBCGDV/subscriptions","organizations_url":"https://api.github.com/users/timlentonBCGDV/orgs","repos_url":"https://api.github.com/users/timlentonBCGDV/repos","events_url":"https://api.github.com/users/timlentonBCGDV/events{/privacy}","received_events_url":"https://api.github.com/users/timlentonBCGDV/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-24T10:22:44Z","updated_at":"2016-02-24T10:24:35Z","closed_at":null,"body":"If I have an optional enum property then the fallback method is not called and the optional is nil, and if I have a non-optional enum property then the fallback method is called however Unbox fails.\r\n\r\nenum Bar: String, UnboxableEnum {\r\n  case Bar1\r\n  case Bar2\r\n  public static func unboxFallbackValue() -> Bar {\r\n    return .Bar1\r\n  }\r\n}\r\n\r\nclass Foo: Unboxable {\r\n  var bar: Bar\r\n  required init(unboxer: Unboxer) {\r\n    self.bar = unboxer.unbox(\"bar\")\r\n  }\r\n}\r\n\r\nUnboxing throws for the code above using this JSON:\r\n\r\n{\"bar\" : \"THIS IS NOT IN THE LIST\"}\r\n\r\nIf I change the Foo class to make bar optional (var bar: Bar?) then unboxFallbackValue is not called. The same happens if the property is missing from the JSON i.e. {} in the example above. \r\n\r\nAm I missing something? Thanks"},"comment":{"url":"https://api.github.com/repos/JohnSundell/Unbox/issues/comments/188180338","html_url":"https://github.com/JohnSundell/Unbox/issues/32#issuecomment-188180338","issue_url":"https://api.github.com/repos/JohnSundell/Unbox/issues/32","id":188180338,"user":{"login":"timlentonBCGDV","id":16870288,"avatar_url":"https://avatars.githubusercontent.com/u/16870288?v=3","gravatar_id":"","url":"https://api.github.com/users/timlentonBCGDV","html_url":"https://github.com/timlentonBCGDV","followers_url":"https://api.github.com/users/timlentonBCGDV/followers","following_url":"https://api.github.com/users/timlentonBCGDV/following{/other_user}","gists_url":"https://api.github.com/users/timlentonBCGDV/gists{/gist_id}","starred_url":"https://api.github.com/users/timlentonBCGDV/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timlentonBCGDV/subscriptions","organizations_url":"https://api.github.com/users/timlentonBCGDV/orgs","repos_url":"https://api.github.com/users/timlentonBCGDV/repos","events_url":"https://api.github.com/users/timlentonBCGDV/events{/privacy}","received_events_url":"https://api.github.com/users/timlentonBCGDV/received_events","type":"User","site_admin":false},"created_at":"2016-02-24T10:24:35Z","updated_at":"2016-02-24T10:24:35Z","body":"(Basically I think the fail state should be cleared if the fallback is used)"}}