0

我有一个奇怪的崩溃,我不知道如何调试......这是代码:

-(void) addEventButtonPressed:(UIButton*)button{
DLog(@"Add new event");
// If event is nil, a new event is created and added to the specified event store. New events are 
// added to the default calendar. An exception is raised if set to an event that is not in the 
// specified event store.
// When add button is pushed, create an EKEventEditViewController to display the event.
EKEventEditViewController *addController = [[EKEventEditViewController alloc] initWithNibName:nil bundle:nil];

// set the addController's event store to the current event store.
addController.eventStore = self.eventStore;
addController.editViewDelegate = self;

// present EventsAddViewController as a modal view controller
[self presentModalViewController:addController animated:YES];

}

我的应用程序在这一行经过很长时间后崩溃:[self presentModalViewController:addController animated:YES];

我正在使用 ARC。有什么线索吗?谢谢!

我的控制台说只是EXC_BAD_ACCESS(code=2, address=0xbf7ffff4)

[编辑] 它似乎eventStore需要在传递给它之前进行初始化,addController否则你会崩溃。就我而言,它是零。

4

1 回答 1

1

确保您从主线程呈现 EKEventEditViewController;如果您从辅助线程呈现它,它将崩溃(并非总是,但通常)。

于 2013-04-11T01:43:33.443 回答