0

Im creating a reminder app.now i use

//NSDate *now = [[NSDate alloc] init];

  //  [datePicker setDate:selected animated:YES];
    //[now release];*

this code and the spinning wheel(in picker) is setting to current time.But i want to set the spinning wheel in picker to the time i previously selected. so is possible to stay at the time the reminder is set at (I.e. if set at 3:00 PM the display on the clock spinner should be 3:00 PM). Can any one help me please.Thanks in advance.

suji
  • 1,470
  • 6
  • 22
  • 41
  • [datePicker setDate:dateobject animated:YES]; in place of date object you can set any date.. – Narayana Rao Routhu Sep 14 '11 at 04:31
  • Save the date how you would otherwise save information in an app. You can use `NSUserDefaults`, or the keychain, or a file on disk.. several methods. Search docs for information on using them. –  Sep 14 '11 at 04:32

1 Answers1

0
  NSDate *pickerTime=timePicker.date;
  [[NSUserDefaults standardUserDefaults] setObject:pickerTime forKey:@"setPickerTime"];
  [[NSUserDefaults standardUserDefaults]synchronize];

While loading the the app next type have the following code in the loadView method,

 NSDate *pickerTime=[[NSUserDefaults standardUserDefaults]objectForKey:@"setPickerTime"];
 if(pickerTime){

    timePicker.date=pickerTime;
}

Hope this helps..

stack2012
  • 2,146
  • 2
  • 16
  • 23
  • timePicker is the UIDatePicker. I use NSUserDefaults to save the current date selected in the picker wheel. So have the first three lines of code in any button click event,which will save the date or time selected in picker at the time when the button is pressed. The last 2 lines will fetch the date stored from the NSUserDefaults using the key "setPickerTime" and set that date in the picker wheel while loading the app again... Hope u can get me.. – stack2012 Sep 14 '11 at 04:34
  • Thanks it worked.but i want to check a condition in viewdid load whether it is loading for first time or not.if it is loading for first time then current time is to be displayed.how to implement this. – suji Sep 14 '11 at 04:44
  • ,u there.do you know how to implement this http://stackoverflow.com/questions/7411506/specially-indicating-or-highlighting-a-toolbar-button-when-a-note-is-added-in-iph – suji Sep 14 '11 at 05:18