从 iPhone 应用程序添加到 iCal 时发生“事件没有日历设置”错误?

发布于 2024-12-13 08:38:45 字数 1155 浏览 2 评论 0原文

我是 iPhone 应用程序开发新手。现在,我正在努力从 iPhone 应用程序向 iCal 添加事件。问题是在向 iCal 添加超过 70 个事件(重复事件)时,这些事件尚未添加到 iCal 中。 iCal 通过错误消息是 ["Error Domain=EKErrorDomain Code=1 "The event has no calendar set." UserInfo=0xfada510 {NSLocalizedDescription=The event has no calendar set.}”]. 如何解决这个问题?请指导我解决这个问题?谢谢,

这是我的代码...

EKEventStore *eventStore = [[EKEventStore alloc] init]; 
EKEvent *events = [EKEvent eventWithEventStore:eventStore];

events.title = @"Title";
events.notes = @"Descriptions";  
events.location = @"Location";
events.startDate = DATE;
events.endDate   = endDates;    
events.availability = EKEventAvailabilityFree;
[events setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
[eventStore saveEvent:events span:EKSpanThisEvent error:&err];
NSLog(@"Error From iCal : %@", [err description]);

NSString *eventID = [[NSString alloc] initWithFormat:@"%@", events.eventIdentifier];
NSLog(@"EventID : %@", eventID);

有时 eventID 返回 null 并且 [err description] 显示错误 [“Error Domain=EKErrorDomain” Code=1“该事件没有设置日历。” UserInfo=0xfada510 {NSLocalizedDescription=该活动没有设置日历。}”]。如何解决这个问题?有什么想法吗?感谢您与我一起度过了宝贵的时间...

Am new to iPhone App development. Now, am struggling with adding event to iCal from iPhone application. The problem is While adding More than 70 events(Repeated events) to iCal the events has not add in iCal. The iCal through the Error message is ["Error Domain=EKErrorDomain Code=1 "The event has no calendar set." UserInfo=0xfada510 {NSLocalizedDescription=The event has no calendar set.}”]. How to solve this problem? Can you please guide me to solve this problem? Where i'm doing wrong? Thanks is advance.

This is my code...

EKEventStore *eventStore = [[EKEventStore alloc] init]; 
EKEvent *events = [EKEvent eventWithEventStore:eventStore];

events.title = @"Title";
events.notes = @"Descriptions";  
events.location = @"Location";
events.startDate = DATE;
events.endDate   = endDates;    
events.availability = EKEventAvailabilityFree;
[events setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
[eventStore saveEvent:events span:EKSpanThisEvent error:&err];
NSLog(@"Error From iCal : %@", [err description]);

NSString *eventID = [[NSString alloc] initWithFormat:@"%@", events.eventIdentifier];
NSLog(@"EventID : %@", eventID);

Sometimes the eventID is return null and The [err description] shows the Error ["Error Domain=EKErrorDomain Code=1 "The event has no calendar set." UserInfo=0xfada510 {NSLocalizedDescription=The event has no calendar set.}”]. How to solve this ? Any ideas? Thanks for spending your valuable time with me...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的心境我的脸 2024-12-20 08:38:45

不知道您是否同时解决了这个问题,但如果没有,您似乎需要首先找到并分配一个日历,如下所示:

EKEventStore *eventStore = [[EKEventStore alloc] init];

EKCalendar *targetCalendar = nil;
targetCalendar = [eventStore defaultCalendarForNewEvents];

if (targetCalendar == nil){
    NSLog(@"The target calendar is nil.");

    //do an alert with only an OK - test this

    [eventStore release];
    return;
}   

NSLog(@"The target calendar is %@.", targetCalendar);

Don't know if you've solved this problem in the meantime but if not, it looks like you need to find and assign a calendar first such as below:

EKEventStore *eventStore = [[EKEventStore alloc] init];

EKCalendar *targetCalendar = nil;
targetCalendar = [eventStore defaultCalendarForNewEvents];

if (targetCalendar == nil){
    NSLog(@"The target calendar is nil.");

    //do an alert with only an OK - test this

    [eventStore release];
    return;
}   

NSLog(@"The target calendar is %@.", targetCalendar);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文