I got an UIDatePicker and want to save its state (only shows hours) after a change.
That works with:
myDate = [datePicker date];
NSUserDefaults *tableDefaults = [NSUserDefaults standardUserDefaults];
tableDefaults setObject:myDate forKey:@"TheDate"];
So how can I get this back to my picker when i relaunch the app?
- (void)viewDidLoad {
if (myDate == nil) {
[datePicker setDate:[NSDate date] animated:NO];
} else {
[datePicker setDate:[myDate date] animated:NO];
}
}
Does not work for me, I just get the normal date / time.
Anyone who knows how to fix this? 🙁
Did you read myDate back out of NSUserDefaults, with code something like this: