我正在尝试将提醒保存在日历中。它已保存但日期和时间错误。
编辑基本上我想在日历中保存提醒,开始日期从 startDate 选择器中选择,结束日期从 endDate 选择器中选择。和从提醒时间选择器中选择的时间。任何日期和时间。
下面是我的代码。我在这里做错了什么
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
event.title = productTextField.text;
[event setCalendar:[eventStore defaultCalendarForNewEvents]];
NSCalendar *calendar = [NSCalendar currentCalendar];
[calendar setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];//This is working
NSDateComponents *components = [calendar components:(NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:[reminderTime getDate]];
NSInteger hour = [components hour];
NSInteger minute = [components minute];
NSDate *reminderDateAndTime = [NSDate dateWithTimeIntervalSince1970: [[startDate getDate] timeIntervalSince1970] + (minute * 60) + (hour * 60 * 60)];
NSDate *endDateAndTime = [NSDate dateWithTimeIntervalSince1970: [[endDate getDate] timeIntervalSince1970] ];
event.startDate = reminderDateAndTime;
event.endDate = endDateAndTime;
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];