title: Is there a better way to save a custom class to NSUserDefaults than encoding and decoding everything with NSCoder?
body: <p>My current class has around 50 lines just encoding and decoding variables in order for my class to be NSUserDefaults compatible. Is there a better way to handle this?</p>
  
  <p>Example: </p>
  
  <pre><code> init(coder aDecoder: NSCoder!) {
      lightEnabled = aDecoder.decodeBoolForKey("lightEnabled")
      soundEnabled = aDecoder.decodeBoolForKey("soundEnabled")
      vibrateEnabled = aDecoder.decodeBoolForKey("vibrateEnabled")
      pulseEnabled = aDecoder.decodeBoolForKey("pulseEnabled")
      songs = aDecoder.decodeObjectForKey("songs") as! [Song]
      currentSong = aDecoder.decodeIntegerForKey("currentSong")
      enableBackgroundSound = aDecoder.decodeBoolForKey("enableBackgroundSound")
      mixSound = aDecoder.decodeBoolForKey("mixSound")
      playSoundInBackground = aDecoder.decodeBoolForKey("playSoundInBackground")
      duckSounds = aDecoder.decodeBoolForKey("duckSounds")
      BPMBackground = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("BPMBackgorund") as! NSData) as! UIColor!
      BPMPulseColor = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("BPMPulseColor") as! NSData) as! UIColor!
      TempoBackGround = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("TempoBackGround") as! NSData) as! UIColor!
      TempoPulseColor = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("TempoPulseColor") as! NSData) as! UIColor!
      TimeBackGround = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("TimeBackGround") as! NSData) as! UIColor!
      TimeStrokeColor = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("TimeStrokeColor") as! NSData) as! UIColor!
      TextColor = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("TextColor") as! NSData) as! UIColor!
  }
  
  func encodeWithCoder(aCoder: NSCoder!) {
      aCoder.encodeBool(lightEnabled, forKey: "lightEnabled")
      aCoder.encodeBool(soundEnabled, forKey: "soundEnabled")
      aCoder.encodeBool(vibrateEnabled, forKey: "vibrateEnabled")
      aCoder.encodeBool(pulseEnabled, forKey: "pulseEnabled")
      aCoder.encodeObject(songs, forKey: "songs")
      aCoder.encodeInteger(currentSong, forKey: "currentSong")
      aCoder.encodeBool(enableBackgroundSound, forKey: "enableBackgroundSound")
      aCoder.encodeBool(mixSound, forKey: "mixSound")
      aCoder.encodeBool(playSoundInBackground, forKey: "playSoundInBackground")
      aCoder.encodeBool(duckSounds, forKey: "duckSounds")
      aCoder.encodeObject(BPMBackground.archivedData(), forKey: "BPMBackground")
      aCoder.encodeObject(BPMPulseColor.archivedData(), forKey: "BPMPulseColor")
      aCoder.encodeObject(TempoBackGround.archivedData(), forKey: "TempoBackGround")
      aCoder.encodeObject(TempoPulseColor.archivedData(), forKey: "TempoPulseColor")
      aCoder.encodeObject(TimeBackGround.archivedData(), forKey: "TimeBackGround")
      aCoder.encodeObject(TimeStrokeColor.archivedData(), forKey: "TimeStrokeColor")
      aCoder.encodeObject(TextColor.archivedData(), forKey: "TextColor")
  }
  </code></pre>