0

I wrote this code but it doesn't work, can you help me please? I'm stuck on it for last 2 hours.

- (IBAction)addBirthday:(id)sender {

    NSString *name = self.textField.text;
    NSDate *date = [self.datePicker date];

    EKEventStore *eventStore = [[EKEventStore alloc] init];
    [eventStore calendarsForEntityType:EKEntityTypeEvent];

    EKEvent *event  = [EKEvent eventWithEventStore:eventStore];
    event.title = [NSString stringWithFormat:@"%@’s Birthday", name];

    event.startDate = date;
    event.endDate   = date;

    NSArray *calendars = [eventStore
                          calendarsForEntityType:EKEntityTypeEvent];

    NSLog(@"ARRAY: %@", [calendars objectAtIndex:0]);

    [event setCalendar: [calendars objectAtIndex:0]];
    NSError *err;
    [eventStore saveEvent:event span:EKSpanThisEvent error:&err];
}
1337code
  • 169
  • 1
  • 3
  • 11

1 Answers1

1

The birthdays calendar is likely read only

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135