2013-08-01 38 views
1

謂詞調用日曆守護進程失敗:錯誤域= EKCADErrorDomain代碼= 1013「操作無法完成(EKCADErrorDomain錯誤1013)」謂詞調用日曆守護進程失敗:錯誤域= EKCADErrorDomain代碼= 1013

我試圖從默認應用程序獲取提醒。

if([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)]) { 
     // need user permission for iOS 6 and later 
     [eventStore requestAccessToEntityType:EKEntityTypeReminder completion:^(BOOL granted, NSError *error) { 
      if (granted) { 
       //---- codes here when user allow your app to access theirs' calendar. 
       [self performCalendarActivity:eventStore]; 
      } 
      else { 
       //----- codes here when user NOT allow your app to access the calendar. 
      } 
     }]; 
    } 

----正在抓取提醒的日期-----

-(void)performCalendarActivity:(EKEventStore*)evtStore 
{ 
    self.eventsList = [[NSMutableArray alloc] initWithArray:0]; 
    int seconds_in_day = 60*60*24;// 1 day = 60*60*24 seconds = 86400 seconds 
    NSDate *endDate = [startDate dateByAddingTimeInterval:seconds_in_day]; 

    // use Dictionary for remove duplicates produced by events covered more one year segment 
    NSMutableDictionary *eventsDict = [NSMutableDictionary dictionaryWithCapacity:1024]; 
    NSDate* currentStart = [NSDate dateWithTimeInterval:0 sinceDate:startDate]; 
    NSDate* currentFinish = [NSDate dateWithTimeInterval:seconds_in_day sinceDate:currentStart]; 

    if ([currentFinish compare:endDate] == NSOrderedDescending) { 
     currentFinish = [NSDate dateWithTimeInterval:0 sinceDate:endDate]; 
    } 
    NSMutableArray *events = [NSMutableArray arrayWithObjects: nil]; 

    NSArray *calendars = [eventStore 
          calendarsForEntityType:EKEntityTypeReminder]; 

    NSPredicate *predicate = [eventStore predicateForRemindersInCalendars:calendars]; 
    //NSPredicate *predicate = [eventStore predicateForIncompleteRemindersWithDueDateStarting:startDate ending:currentFinish calendars:calendars]; 
    [eventStore fetchRemindersMatchingPredicate:predicate completion:^(NSArray *ekReminders){ 
     [events addObjectsFromArray:ekReminders]; 
    }]; 
} 

我收到此錯誤: - 謂詞調用日曆守護進程失敗:錯誤域= EKCADErrorDomain代碼= 1013「操作無法完成(EKCADErrorDomain error 1013.)」

請幫忙。

+0

可能重複的[defaultCalendarForNewEvents失敗](http://stackoverflow.com/questions/12454324/defaultcalendarfornewevents-failed) – jrc

回答

2

該警告是因爲用戶未授予訪問提醒的權限。

快速修復:

  1. 轉到設置
  2. 選擇隱私
  3. 選擇提醒
  4. 選擇你的應用程序,並允許 「提醒」 爲開的訪問。
+0

不適用於我。 – frank

+0

@frank您是否刪除了您的應用並嘗試過? – HDdeveloper

+1

我解決了這個問題。這是因爲我的EKEntityType錯了。我設置了EKEntityTypeReminder類型,但我讀了EKEvent.So它抱怨。你的方法是對的,謝謝你。 – frank

相關問題