从iPhone App向iCal添加事件,事件没有日历集错误? [英] Add events to iCal from iPhone App, The event has no calendar set Error?

查看:476
本文介绍了从iPhone App向iCal添加事件,事件没有日历集错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,在添加多个事件超过70个事件一次又一次从我们的iPhone应用程序的iCal。前20个事件添加到iCal没有任何问题。后的余额事件不添加到iCal。来自iCal的错误日志显示给定的

I have one problem while adding multiple events more than 70 events repeatedly again and again to the iCal from our iPhone application. First 20 events add to iCal without any issues. After the balance events not adding to iCal. The error log from the iCal shows the given


错误,[错误域= EKErrorDomain代码= 1事件没有日历
set。UserInfo = 0xfada510 {NSLocalizedDescription =该活动没有
日历集。}]。

Error, ["Error Domain=EKErrorDomain Code=1 "The event has no calendar set." UserInfo=0xfada510 {NSLocalizedDescription=The event has no calendar set.}"].

我已附加我的代码,请帮助我解决这个问题。

Below i have attached my code. Please help me to solve this problem.

int count = [eventsArray Count];
for(int i=0;i<count;i++)
{
    EKEventStore *eventStore = [[EKEventStore alloc] init]; 
    EKEvent *events = [EKEvent eventWithEventStore:eventStore];

    events.title = @"Apple";
    events.notes = @"Apple iPhone";  
    events.location = @"US";
    events.startDate = today;
    events.endDate   = tomorrow;    
    events.availability = EKEventAvailabilityFree;
    [events setCalendar:[eventStore defaultCalendarForNewEvents]];
    NSError *error;
    [eventStore saveEvent:events span:EKSpanThisEvent error:&error];
    NSLog(@"Error From iCal : %@", [error description]);

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

计数可能超过70(有时只会有20-30个事件)。
此代码在For循环中。这段代码执行将近70次。 iCal错误日志显示错误此事件没有设置日历,并且eventid返回Null。如何克服这个问题。请帮我解决这个。先感谢。

The count maybe more than 70(sometimes it will be only 20-30 events). This code is in For loop. This code will execute nearly more than 70 times. The iCal error log displays the error "This event has no calendar set" and the eventid returns Null. How to overcome this problem. Please help me to solve this. Thanks in advance.

推荐答案

非常感谢您的回应。我找到了问题的原因。只有当我一次向iCal添加多个事件时,问题才会发生,EKEventStore将丢失日历集。这就是错误消息错误,[错误域= EKErrorDomain代码= 1事件没有设置日历。 UserInfo = 0xfada510 {NSLocalizedDescription =该事件没有设置日历}}]]来自iCal,我在循环条件中做了一个简单的更改,也就是说,我已经延迟添加一个事件到iCal 3秒的时间间隔添加事件(对不起,我的可怜的英语)。这意味着每个事件将添加到iCal后3秒的延迟,从上一个事件添加在iCal。现在,它似乎工作正常我已经测试了这个条件,感觉很好,再次感谢你。

Thank you so much for your responses. I have found the reason of the problem. The problem is occur only when i'm adding multiple events to iCal at a time, the EKEventStore will lost the calendar set. That is the reason the error message "Error, ["Error Domain=EKErrorDomain Code=1 "The event has no calendar set." UserInfo=0xfada510 {NSLocalizedDescription=The event has no calendar set.}"]" has came from iCal. I did a simple change in loop condition. That is, i have delayed to add an events to iCal by 3 sec's time interval for each adding events (Sorry for my poor english). This means every events will add to iCal after 3sec's delay from previous event added on iCal. Now, it seems working fine. I have tested this condition and feel good. Once again i thank you all.

Yuvaraj.M

Yuvaraj.M

这篇关于从iPhone App向iCal添加事件,事件没有日历集错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆