tags:

views:

58

answers:

0

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.

Any help would be appreciated.

Thanks!

// create the custom color

UIColor *selectedColor = [UIColor colorWithRed:0.0 green:0.5 blue:0.0 alpha:1.0];

// save the color to user defaults

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];