title: How do I encode enum using NSCoder in swift?
body: <p><strong>Background</strong></p>
  
  <p>I am trying to encode a String-style enum using the NSCoding protocol, but I am running into errors converting to and back from String.</p>
  
  <p>I get the following errors while decoding and encoding:</p>
  
  <p><em>String is not convertible to Stage</em></p>
  
  <p><em>Extra argument ForKey: in call</em></p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>    enum Stage : String
      {
          case DisplayAll    = "Display All"
          case HideQuarter   = "Hide Quarter"
          case HideHalf      = "Hide Half"
          case HideTwoThirds = "Hide Two Thirds"
          case HideAll       = "Hide All"
      }
  
      class AppState : NSCoding, NSObject
      {
          var idx   = 0
          var stage = Stage.DisplayAll
  
          override init() {}
  
          required init(coder aDecoder: NSCoder) {
              self.idx   = aDecoder.decodeIntegerForKey( "idx"   )
              self.stage = aDecoder.decodeObjectForKey(  "stage" ) as String    // ERROR
          }
  
          func encodeWithCoder(aCoder: NSCoder) {
              aCoder.encodeInteger( self.idx,             forKey:"idx"   )
              aCoder.encodeObject(  self.stage as String, forKey:"stage" )  // ERROR
          }
  
      // ...
  
      }
  </code></pre>