ios - 对日历守护程序的谓词调用失败 : Error Domain=EKCADErrorDomain Code=1013

标签 ios calendar ekevent ekeventkit ekeventstore

对日历守护程序的谓词调用失败:错误域=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 错误 1013。)”

请帮忙。

最佳答案

警告是因为用户没有授予访问提醒的权限。

快速修复:

  1. 转到设置
  2. 选择隐私
  3. 选择提醒
  4. 选择您的应用程序并允许访问“提醒”。

关于ios - 对日历守护程序的谓词调用失败 : Error Domain=EKCADErrorDomain Code=1013,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17994127/

相关文章:

ios - 如何使这个自动布局安排与 ScrollView 一起工作

ios - 如何禁用 UIDatePicker 中的特定日期

javascript - Google Calendar API 获取事件详细信息

ios - 使用具有神奇记录的多个键进行排序时找不到键路径

ios - 如何将 JWT token 传递给 socket.io swift?

iphone - 在不使用 UITabBarController 创建项目的情况下使用 UITabBar

iphone - 将 .ics 文件导入 iOS 用户日历

swift - 如何从默认日历中删除所有事件

ios - requestAccessToEntityType :completion: has been deprecated calling this is no longer allowed. 改为使用 requestFullAccessToEventsWithCompletion:

ios - -webkit-transform 阻止页面加载