Wie kombiniere ich Datum und Uhrzeit von zwei UIDatePickern?

ich habe zweiUIDatePickers In meiner App dient ein Modus zum Auswählen des Datums und ein anderer zum Auswählen der Uhrzeit. Ich habe eine Benachrichtigung ausgelöst, wenn das genaue Datum und die Uhrzeit erreicht sind. Ich kann die Erinnerung zur richtigen Zeit auslösen, aber das Problem ist, dass das Datum nicht überprüft wird. Gibt es eine Möglichkeit, Datum und Uhrzeit gleichzeitig zu überprüfen?

Vielen Dank im Voraus ...

Bearbeiten

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];

Antworten auf die Frage(2)

Ihre Antwort auf die Frage