在iOS应用程序中打开.ics文件

我需要在我的应用程序中打开一个.ics文件。

我试图打开它像这样:

NSURL *path = [[NSBundle mainBundle] URLForResource:@"myIcsName" withExtension:@"ics"]; [[UIApplication sharedApplication] openURL:path]; 

但没有任何事情发生。

如何打开.ics文件?

我只使用了下面的代码:

 - (IBAction)displayICS:(id)sender { NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"ics"]; NSURL *url = [NSURL fileURLWithPath:path]; UIDocumentInteractionController *dc = [UIDocumentInteractionController interactionControllerWithURL:url]; dc.delegate = self; [dc presentPreviewAnimated:YES]; } -(UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller { return self; } 

我发现有两个项目可以让你打开一个ICS文件,并以Objective-C对象的forms获取事件,date和其他信息。

MXLCalendarManager似乎有点进一步,将允许您从date的ICS文件search中提取事件,并将事件添加到用户iOS日历。 这可能是你要找的。 GitHub项目MXLCalendarManager它也支持写入新的ICS文件。

我创build了一个项目,使用C语言编写的libical库来parsing完整的ICS文件。 这个项目还处于初期阶段,在准备好投入项目之前可以使用更多的投标。 你可以在Github Project XbICalendar查看更多关于libical的细节可以在GitHub Project libical