2
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 frequency;

NSError *error = nil;

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

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

above code is set to alarm is fine but When i reset the simulator call this method showing the this error Error getting default calendar for new reminders:

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

and the again stop and build the application working fine.Why this error coming first time launching

Midhun MP
  • 103,496
  • 31
  • 153
  • 200
mano
  • 47
  • 1
  • 8

1 Answers1

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];
}

or may be have following problem Quick Fix:

  1. Goto Settings
  2. Select Privacy
  3. Select Reminders
  4. Choose your application and allow access of "Reminders" to ON.
Midhun MP
  • 103,496
  • 31
  • 153
  • 200
Hitesh Surani
  • 12,733
  • 6
  • 54
  • 65