我想在我的iPhone 日历中添加事件,我成功地将事件添加到我的 iPhone 日历中。但是,我想获取所有 Current Month 事件,并且我想在我的MFMailComposer中附加该事件文件(.ical)。
问问题
624 次
2 回答
3
读取事件非常简单。
// Create the predicate from the event store's instance method
NSPredicate *predicate = [store predicateForEventsWithStartDate:startOfTheMonth
endDate:endOfTheMonth
calendars:nil];
// Fetch all events that match the predicate
NSArray *events = [store eventsMatchingPredicate:predicate];
苹果文档中的更多信息。
要获得本月的开始和结束,您可以使用此项目中的示例:https ://github.com/melsam/NSDateCategoryForReporting
并以此为例如何将事件导出到 .ical 文件 https://github.com/mysterioustrousers/EKEventToiCal/blob/master/EKEventToiCal/
要发送 .ical 文件,请使用 IronManGill 答案中的代码,但将 mimeType 更改为 text/calendar
[picker addAttachmentData:data mimeType:@"text/calendar" fileName:@"/abc.ical"];
于 2013-08-07T08:33:17.100 回答
0
好吧,我可以为您提供一种解决方法。如果您获得.ical 文件,则可以访问它。您可以将其转换为.zip 文件,请通过以下链接:-
在 ObjectiveC for iPhone 中创建 zip 文件
然后将其与使用此电子邮件的电子邮件一起附加MFMailComposer
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *WritableDBPath= [documentsDirectory stringByAppendingPathComponent:kFilename];
NSData *data = [NSData dataWithContentsOfFile:WritableDBPath];
[picker addAttachmentData:data mimeType:@"application/zip" fileName:@"/abc.zip"];
[picker setSubject:@"Database"];
[picker setMessageBody:@"Database testing" isHTML:NO];
[self presentModalViewController:picker animated:YES];
希望这可以帮助。
于 2013-08-07T09:10:44.003 回答