使用EKEventEditViewController时崩溃 [英] crash when using EKEventEditViewController
问题描述
我有一个奇怪的崩溃,我不知道如何调试...
这是代码:
I have a weird crash that I don't know how to debug... Here is the code:
-(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];
My app crashes after a looong time at this line: [self presentModalViewController:addController animated:YES];
我正在使用ARC。
任何线索?
谢谢!
I am using ARC. Any clues? Thanks!
我的控制台只是说 EXC_BAD_ACCESS(代码= 2,地址= 0xbf7ffff4)
似乎 eventStore
需要在传递给 addController $之前进行初始化c $ c>或者你遇到了崩溃。在我的情况下,它是零。
It seems eventStore
needs to be initialized before passing it to addController
or you get a crash. In my case it was nil.
推荐答案
确保您从主线程呈现EKEventEditViewController;如果你从辅助线程中呈现它,它将崩溃(并不总是,但通常)。
Make sure that you are presenting the EKEventEditViewController from the main thread; it will crash (not always, but usually) if you present it from a secondary thread.
这篇关于使用EKEventEditViewController时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!