我有一個問題,一次又一次地從我們的iPhone應用程序向iCal重複添加多個事件超過70個事件。前20個活動添加到iCal中沒有任何問題。平衡事件沒有添加到iCal之後。從iCal的錯誤日誌顯示給定從iPhone App將事件添加到iCal,事件沒有設置日曆錯誤?
錯誤,[「錯誤域= EKErrorDomain代碼= 1‘的事件沒有日曆 集。’的UserInfo = 0xfada510 {NSLocalizedDescription =事件沒有 日曆集。 }」]。
下面我重視我的代碼,請幫我解決這個問題。
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。如何克服這個問題。請幫我解決這個問題。提前致謝。
請幫我解決問題....謝謝.. –
你能後的環片斷,你的每一次迭代創建EKEventStore?你有沒有試過在上面的代碼不一個循環? – Ryan
感謝您的迴應。以上代碼在我的循環中...我正在創建EKEventStore a t每一次迭代..如果它不是在循環工作完美..只有錯誤發生for循環(添加多個事件到iCal)..我做錯了什麼地方?我需要做些什麼來解決這個問題?請幫助我....謝謝... –