Iphone 在iOS上的iCloud上添加日历
我正在尝试将日历添加到iCloud EKSource,我正在尝试通过以下方式查找iCloud日历:Iphone 在iOS上的iCloud上添加日历,iphone,ios,icloud,ekeventstore,Iphone,Ios,Icloud,Ekeventstore,我正在尝试将日历添加到iCloud EKSource,我正在尝试通过以下方式查找iCloud日历: EKSource *theSource = nil; for (EKSource *source in eventStore.sources) { if (source.sourceType == EKSourceTypeCalDAV && [source.title isEqualToString:@"iCloud"]) { theSource = source;
EKSource *theSource = nil;
for (EKSource *source in eventStore.sources) {
if (source.sourceType == EKSourceTypeCalDAV && [source.title isEqualToString:@"iCloud"]) {
theSource = source;
break;
}
}
但是找不到我的任何EKSource,我如何在icloud上添加日历并查看icloud中有多少日历?也许类似的东西会对您有所帮助
- (void)saveEventToiCloud {
EKEventStore *eventDB = [[EKEventStore alloc] init];
NSArray *calender = [[eventDB calendars] retain];
NSString * typeString = @"";
EKCalendar *iCloud;
for (EKCalendar *thisCalendar in calenders)
{
EKCalendarType type = thisCalendar.type;
if (type == EKCalendarTypeCalDAV)
{
NSString *calName=[NSString stringWithFormat:@"%@", thisCalendar.title];
NSRange range = [calName rangeOfString:@"iCloud"]; //Couldn't find better way, if there is, then tell me too. :)
if(range.length!=0)
{
//icloud
iCloud = thisCalendar;
break;
}
else
{
//any other email account
}
}
}
if(iCloud){
NSError *error = nil;
EKEvent *thisEvent = [[EKEvent eventWithEventStore:eventDB] retain];
thisEvent.title = @"Title";
thisEvent.startDate = [NSDate date];
thisEvent.endDate = [NSDate date];
thisEvent.calendar = iCloud ;
BOOL saved = [eventDB saveEvent:thisEvent span:EKSpanThisEvent error:&error];
NSLog(@"Saved calendar event = %@\n", (saved ? @"YES" : @"NO"));
[thisEvent release];
thisEvent=nil;
}
[events release];
[eventDB release];
}
设备中有什么操作系统版本?设备中是否配置了iCloud?是的,iCloud已配置,我有ios 6…您必须请求访问权限才能访问ios 6中的日历,请参阅。通过这种方式,可以为我找到EKCalendarTypeDav,但它不是iCloud日历…我不明白为什么找不到它…您是否可以尝试使用
NSRange range=[calName rangeOfString:@”]代码>然后其他部分将是您的iCloud。