我写了这段代码,但它不起作用,你能帮我吗?我已经坚持了 2 个小时了。
- (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];
}
最佳答案
生日日历可能是只读的
关于iphone - 在 iOS 中将事件添加到生日日历,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13430206/