我想使用 eventkit 将服务器中的事件添加到 ical 中。我可以通过编程方式订阅一个 url,以便所有事件都可以在 ical 应用程序中自动同步。
Best Answer-推荐答案 strong>
Synchronization is done from your side (Inside objective "c"). You need to fetching all events from server after hitting appropriate URL.
Parse it and save single event with the help of below method:
-(void)addingEvents{
EKEventStore *eventStore = [[EKEventStore alloc] init];
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
event.title = <<Event Title>>;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat: @"yyyy-MM-dd hh:mma"];
[dateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
NSString *strDate = [dateFormatter stringFromDate:<<Your event date>>];
NSDate *startDate = [dateFormatter dateFromString:strDate];
[dateFormatter release];
event.startDate = [[NSDate alloc] initWithTimeInterval:0 sinceDate:startDate];
event.endDate = [[NSDate alloc] initWithTimeInterval:600 sinceDate:event.startDate];
NSArray *alertArray = [NSArray arrayWithObject:[EKAlarm alarmWithRelativeOffset:-300]];
event.alarms = alertArray;
[event setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];
if (err) {
NSLog(@"Error occured : %@",[err localizedDescription]);
}
[eventStore release];
}
关于iphone - 订阅 url 以在 ical 中添加事件,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/15292515/
|