我已经在此日期范围内的EKCalendar中保存了28个EKEvent : 2012-01-01和2013-01-18,这些EKEvent都已存储,我可以在iCloud上的iOS日历中看到它,然后我希望检索2012-01-01和2013-01-18范围内的所有EKEvent,并使用此EKEventStore方法:
predicateForEventsWithStartDate:endDate:calendars:这是一个在日历中获取事件的NSPredicate,我传递了开始日期2012-01-01,结束日期:2013-01-18,所以用EKEvent返回的数组只有8个元素,所以我的问题是为什么它没有找到所有28个事件?我做错了什么?
编辑:
这是我使用的完整代码:
NSDate* sourceDate2 = [dateFormat dateFromString:@"2012/01/01"];
NSTimeZone* sourceTimeZone2 = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
NSTimeZone* destinationTimeZone2 = [NSTimeZone systemTimeZone];
NSInteger sourceGMTOffset2 = [sourceTimeZone2 secondsFromGMTForDate:sourceDate2];
NSInteger destinationGMTOffset2 = [destinationTimeZone2 secondsFromGMTForDate:sourceDate2];
NSTimeInterval interval2 = destinationGMTOffset2 - sourceGMTOffset2;
NSDate* destinationDate2 = [[NSDate alloc] initWithTimeInterval:interval2 sinceDate:sourceDate2];
NSTimeInterval time2 = floor([destinationDate2 timeIntervalSinceReferenceDate] / 86400.0) * 86400.0;
NSDate *startDate = [NSDate dateWithTimeIntervalSinceReferenceDate:time2];然后,我使用相同的代码来创建2013-01-18日期,也就是endDate,然后执行以下操作:
EKEventStore *eventStore = [[EKEventStore alloc] init];
NSPredicate *predicateEvent = [eventStore predicateForEventsWithStartDate:startDate endDate:endDate calendars:[eventStore calendarsForEntityType:EKEntityTypeEvent]];
NSArray *eventArray = [eventStore eventsMatchingPredicate:predicateEvent];eventArray只包含8个elements...and,其他20个在哪里?求求你,我要疯了,有人能帮帮我吗?
发布于 2013-01-25 02:35:13
在您的设备上,转到:Settings > Mail, Contacts, Calendars,然后在Calendars子部分下转到Sync > All Events。不只是过去30天、60天等的事件。
https://stackoverflow.com/questions/13812281
复制相似问题