title: How to save custom color to UserDefaults
body: <p>I am trying to use some non-standard colors (i.e. not UIColor blueColor, but a darker blue color, a darker green, red...etc...) and when I try to save the user selected UIColor object to UserDefaults, it is failing. Below is the code I am using to create the custom colors, followed by the code to save the UIColor objects to the UserDefaults.</p>
  
  <p>Any help would be appreciated.</p>
  
  <p>Thanks!</p>
  
  <p>// create the custom color</p>
  
  <pre><code>UIColor *selectedColor = [UIColor colorWithRed:0.0 green:0.5 blue:0.0 alpha:1.0];
  </code></pre>
  
  <p>// save the color to user defaults</p>
  
  <pre><code>NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
  // archive it into a data object
  
  /*** Fails on this next line ***/    
  NSData *dataColor = [NSKeyedArchiver archivedDataWithRootObject: selectedColor];
  
  // write the data into the user defaults
  [prefs setObject: dataColor forKey:colorKey];
  
  [prefs synchronize];
  </code></pre>