How can I get the local calendar after log in iClo

2019-09-07 01:57发布

问题:

I met a problem when using the iOS Calendar(EventKit). My Calendar Event is created and stored in the EKEventStore(Type is EKSourceTypeLocal), when I login iCloud account, I can't get the event witch I created before.

Sure,when I login iCloud,It said that I can merge my local device data to iCloud Clendar,if I choose YES,the local device data will be merged in iCloud,Then I can find my event using event type 'EKSourceTypeCalDAV',But I don't want sync it to my iCloud calendar.

I can't find my local event anywhere(If don't merge to iCloud)..please help,thanks!

回答1:

- (BOOL)isICloudAccountLogin {
    for (EKSource *tempSource in self.eventStore.sources) {
        if (tempSource.sourceType == EKSourceTypeCalDAV && [tempSource.title isEqualToString:@"iCloud"]) {
            EKSource *localSource = [self sourceInEventStore:[EventManager getInstance].eventStore sourceType:EKSourceTypeCalDAV sourceTitle:@"iCloud"];
            NSArray *calendarArray = [self getAllCategoryOfCalendarBySource:localSource andCalendarType:EKCalendarTypeCalDAV andEventType:EKEntityTypeEvent];
            if ([calendarArray count] <= 0) {
                return NO;
            }
            return YES;
        }
    }
    return NO;
}

I use this code to check if iCloud Account has login.And handle other process in different EKSource.



标签: ios calendar