【发布时间】:2012-09-27 01:42:14
【问题描述】:
我的 iPad 上有两 (2) 个日历 (iCal)(一个用于个人,一个用于应用程序)。它们同步到我的 iMac 仅用于测试。 (节省了我输入特定应用日历的时间)。
我目前正在编写一个需要访问应用程序日历的应用程序。它是 iPad 上的主日历。我正在尝试让 Apple 的 SimpleEKDemo(未修改)与应用程序的日历一起使用,但到目前为止,我什至无法让它不崩溃,更不用说返回任何东西了。几个小时以来,我一直在研究 Google 和 SO 的问题,并决定是时候召集大佬了。
这是崩溃的代码:
- (void)viewDidLoad
{
self.title = @"Events List";
// Initialize an event store object with the init method. Initilize the array for events.
self.eventStore = [[EKEventStore alloc] init];
self.eventsList = [[NSMutableArray alloc] initWithArray:0];
// Get the default calendar from store.
self.defaultCalendar = [self.eventStore defaultCalendarForNewEvents]; // <---- crashes here --------
// Create an Add button
UIBarButtonItem *addButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:
UIBarButtonSystemItemAdd target:self action:@selector(addEvent:)];
self.navigationItem.rightBarButtonItem = addButtonItem;
[addButtonItem release];
self.navigationController.delegate = self;
// Fetch today's event on selected calendar and put them into the eventsList array
[self.eventsList addObjectsFromArray:[self fetchEventsForToday]];
[self.tableView reloadData];
}
这是“崩溃”的输出:
2012-10-05 14:33:12.555 SimpleEKDemo[874:907] defaultCalendarForNewEvents failed: Error Domain=EKCADErrorDomain Code=1013 "The operation couldn’t be completed. (EKCADErrorDomain error 1013.)"
我需要确保我在正确的日历上...我该怎么做?
【问题讨论】:
-
崩溃的输出是什么?
-
糟糕...我编辑了问题以添加它...抱歉...
-
OK... 我将代码更改为: // 从商店获取默认日历。 self.defaultCalendar = [self.eventStore calendarWithIdentifier:@"Prager Software"];但它似乎没有工作,因为它在“获取今天的事件”上崩溃,因为那里什么都没有。如何验证日历的名称?
标签: objective-c xcode4 icalendar