我需要创建将所有 iCal 事件导出到 isc 文件的应用程序。你能告诉我该怎么做吗?使用 Cocoa 应用程序、命令行工具还是 AppleScript 应用程序?....我正在尝试使用 AppleScript 应用程序执行此操作,使用 CalendarStore 框架。我能够获取所有事件,但是如何将它们保存到 ics 文件?
这是我的代码:
- (IBAction)btnSelector:(id)sender {
CalCalendarStore *calendarStore = [CalCalendarStore defaultCalendarStore];
NSDate *startDate=[[NSDate alloc] init];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init] ;
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
startDate=[formatter dateFromString:@"2010-01-01 00:00:00"];
NSDate *endDate=[[NSDate alloc] init];
endDate=[formatter dateFromString:@"2050-01-01 00:00:00"];
NSArray *calendars = [calendarStore calendars];
NSPredicate *allEventsPredicate = [CalCalendarStore eventPredicateWithStartDate:startDate endDate:endDate calendars:[calendarStore calendars]];
NSArray *events = [calendarStore eventsWithPredicate:allEventsPredicate];
for(CalEvent *event in events)
{
//here i must save event to file...
NSLog(@"%@",event);
}
for (CalCalendar *calendar in calendars) {
self.lblNotification.title=[NSString stringWithFormat:@"%@ %@",self.lblNotification.title,calendar.title];
}
}