【问题标题】:Error Domain=EKCADErrorDomain Code=1013 "The operation couldn’t be completed. (EKCADErrorDomain error 1013.)" [duplicate]错误域 = EKCADErrorDomain 代码 = 1013 “操作无法完成。(EKCADErrorDomain 错误 1013。)” [重复]
【发布时间】:2015-09-28 07:50:39
【问题描述】:
EKReminder *reminder = [EKReminder reminderWithEventStore:self.eventStore];
reminder.title       = @"E-Cold 1mg";
reminder.calendar    = [_eventStore defaultCalendarForNewReminders];
NSDate *date         = [_myDatePicker date];

// get today date
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; // here we create NSDateFormatter object for change the Format of date..
[dateFormatter setDateFormat:@"YYY-MM-dd"]; //Here we can set th

NSLog(@"%@",[dateFormatter stringFromDate:date]);
EKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:date];

[reminder addAlarm:alarm];

// EKRecurrenceFrequency 频率;

NSError *error = nil;

[_eventStore saveReminder:reminder commit:YES error:&error];

if (error)
{
    NSLog(@"error = %@", error);
}`

上面的代码设置为警报很好,但是当我重置模拟器时调用此方法显示此错误错误获取新提醒的默认日历:

Error Domain=EKCADErrorDomain Code=1013 "The operation couldn’t be completed. (EKCADErrorDomain error 1013.)"
 error = Error Domain=EKErrorDomain Code=1 "No calendar has been set." UserInfo=0x7f8fca4eac80 {NSLocalizedDescription=No calendar has been set.}

然后再次停止并构建应用程序工作正常。为什么第一次启动时出现此错误

【问题讨论】:

    标签: ios eventkit


    【解决方案1】:
    EKEventStore *eventStore = [[[EKEventStore alloc] init] autorelease];
    if ([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)]) {
        // iOS 6 and later
        [eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
            if (granted) {
                // code here for when the user allows your app to access the calendar
                [self performCalendarActivity:eventStore];
            } else {
                // code here for when the user does NOT allow your app to access the calendar
            }
        }];
    } else {
        // code here 
        [self performCalendarActivity:eventStore];
    }
    

    或者可能有以下问题 快速修复:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-10
      • 1970-01-01
      • 2014-11-02
      • 2018-12-16
      • 2017-07-09
      • 2012-04-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多