开发者

programatically adding a calendar event on iPad

I have a button on my iPad, on clicking it, an entry on the calendar should be created with a specific title and default time duration of 30min. How can I do that ? I have reached a point where I have inheritted the calendar object and also able to read it also开发者_开发知识库.

Question: How do I add the entry to it from the code ?


I pasted this from my code... post a comment if you have any confusion

EKEventStore *eventStore = [[EKEventStore alloc] init];

EKEvent *event  = [EKEvent eventWithEventStore:eventStore];
event.title     = @"EVENT TITLE";
event.notes     = @"Event notes here";
event.startDate = [[NSDate alloc] init];
event.endDate   = [[NSDate alloc] initWithTimeInterval:600 sinceDate:event.startDate];

[event setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];  
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜