我在EKCalendar中的EKCalendar中保存了28個EKEvent,日期範圍爲2012-01-01和2013-01-18,EKEvent全部存儲,我可以看到它在iCloud上的iOS日曆,然後我想找回這一切EKEvent範圍2012-01-01和2013年1月18日我用EKEventStore的這種方法:predicateForEventsWithStartDate:endDate:日曆:EKEventStore不起作用
predicateForEventsWithStartDate:endDate:calendars:
是在NSPredicate來獲取事件日曆,我通過開始日期2012-01-01和endDate: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年1月18日日期是在結束日期,那麼我這樣做:
EKEventStore *eventStore = [[EKEventStore alloc] init];
NSPredicate *predicateEvent = [eventStore predicateForEventsWithStartDate:startDate endDate:endDate calendars:[eventStore calendarsForEntityType:EKEntityTypeEvent]];
NSArray *eventArray = [eventStore eventsMatchingPredicate:predicateEvent];
eventArray只包含8個元素......其他20個在哪裏?請我瘋了別人能幫助我嗎?
是在同一個'EKCalendar'中的28'EVEvent's?你可以發佈完整的代碼,試圖獲取你的'EKEvent'嗎? – holex
是在同一個日曆中... – Piero
你能顯示你的代碼嗎? – holex