Jak połączyć datę i godzinę z dwóch UIDatePickers?

mam dwaUIDatePickers w mojej aplikacji jeden tryb służy do wybierania daty, a inny do trybu czasu. Po otrzymaniu dokładnej daty i godziny wysłałem powiadomienie. Mogę uruchomić przypomnienie w odpowiednim czasie, ale problem polega na tym, że data nie jest zaznaczona. Czy można sprawdzić datę i godzinę w tym samym czasie?

Dzięki z góry ...

Edytować

NSDate *date1 = [datePicker date];
NSDate *date2 = [timePicker date];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

unsigned unitFlagsDate = NSYearCalendarUnit | NSMonthCalendarUnit |  NSDayCalendarUnit;
NSDateComponents *dateComponents = [gregorian components:unitFlagsDate fromDate:date1];
unsigned unitFlagsTime = NSHourCalendarUnit | NSMinuteCalendarUnit ;
NSDateComponents *timeComponents = [gregorian components:unitFlagsTime fromDate:date2];

[dateComponents setHour:[timeComponents hour]];
[dateComponents setMinute:[timeComponents minute]];

NSDate *combDate = [gregorian dateFromComponents:dateComponents];   

UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil) return;
NSDate *fireTime = combDate;
localNotif.fireDate = fireTime;
localNotif.alertBody = @"Alert!";
localNotif.soundName = UILocalNotificationDefaultSoundName;  
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];

questionAnswers(2)

yourAnswerToTheQuestion