As you can see from the screenshot below I have a countdown clock that I am allowing the user to change the color of buttons and labels on the UI. My problem is, is that I want the user to be able save their color settings, however I cannot figure out placement and order. I understand this question has been answered here: Saving UIColor to and loading from NSUserDefaults.
However, I guess I'm not "getting it" and need the extra help. So each of the colors on the screenshot below have coding like this:
-(IBAction)red
{
[_enterDateOutlet setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[_backButtonOutlet setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
_yearsLabel.textColor = [UIColor redColor];
_daysLabel.textColor = [UIColor redColor];
_hoursLabel.textColor = [UIColor redColor];
_minLabel.textColor = [UIColor redColor];
_secLabel.textColor = [UIColor redColor];
minuteProgessView.theme.labelColor = [UIColor redColor];
secondProgessView.theme.labelColor = [UIColor redColor];
hourProgessView.theme.labelColor = [UIColor redColor];
dayProgessView.theme.labelColor = [UIColor redColor];
yearProgessView.theme.labelColor = [UIColor redColor];
}
My question is do I put this code at the end of each Color Action button (I have 7 colors)?
NSData *colorData = [NSKeyedArchiver archivedDataWithRootObject: color];
[[NSUserDefaults standardUserDefaults] setObject:colorData forKey:@"color1"];
Because that's what I figured I was supposed to do, and then I added this to my View Did Load Method:
NSData *colorData = [[NSUserDefaults standardUserDefaults] objectForKey:@"myColor"];
UIColor *color = [NSKeyedUnarchiver unarchiveObjectWithData:colorData];
And the result a red error, because "color" was undeclared identifier.
I would really appreciate the help, I'm new to this and I've spent the last 2 hours trying to figure this out. Thank you.