1

この範囲の日付で EKCalendar に 28 の EKEvent を保存しました: 2012-01-01 および 2013-01-18、EKEvent はすべて保存され、iCloud の iOS カレンダーで確認できます。次に、このすべての EKEvent を取得します2012-01-01 と 2013-01-18 の範囲で、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];

次に、同じコードを使用して endDate である 2013-01-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 はどこにありますか? 誰か私を助けてくれませんか?

4

1 に答える 1

2

デバイスで、 に移動し、サブセクションSettings > Mail, Contacts, Calendarsの下にある に移動します。過去 30 日間、60 日間などのイベントだけではありません。CalendarsSync > All Events

于 2013-01-24T18:35:13.077 に答える