How to get time with datePicker and run the method at this time?

I want to get the time with datePicker in an NSDate object, and then run the method every day at this time. for example: the user inserted datePicker in the message at 08:00 and every day at 08:00 the application will run some method.

Thanks a lot, Amir Vogel

+5
source share
1 answer

To get time from using datepicker,

NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"HH:mm"]; //24hr time format
NSString *dateString = [outputFormatter stringFromDate:self.myDatePicker.date];
[outputFormatter release];

For daily use of functionality at a specific time UILocalNotification .

Set repeatInterval as NSDayCalendarUnit.

And in the delegate for handling UILocalNotification code, your method.

. , .

+12

All Articles