错误域= EKCADErrorDomain代码= 1013 “该操作不能完成(EKCADErrorDomain错误1013)。”

问题描述:

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频率;错误域= EKCADErrorDomain代码= 1013 “该操作不能完成(EKCADErrorDomain错误1013)。”

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.} 

和再次停止并构建应用程序的工作fine.Why这个错误即将首次推出

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. 选择你的应用程序,并允许“提醒”为开的访问。