views:

232

answers:

1

I have a UIDatePicker that well, allows you to select a date (not time). I then save this NSDate and use display it in a label on a different view. However, when I load back the view with the UIDatePicker, if the user has already selected a date, I want it to show that selected date (using NSDefaultPrefs). How do I do this?

I know how to do it for a normal UIPickerView, but how does it work if it is a date?

Thanks.

+1  A: 

You save and restore the date however you want (in a DB, NSDefaults, etc). Once you have the date you want to set it to you just call -[UIDatePicker setDate:animated:], so something like this:

- (void)viewDidLoad {
  [super viewDidLoad];
  [datePicker setDate:myDate animated:NO];
}
Louis Gerbarg