从不同控制器访问时 EKEventstore 崩溃
我是新来的,但我已经读了很多书。大多数情况下,我找到了我正在寻找的东西,但现在我陷入了困境。阅读文档并询问谷歌并没有帮助,所以我开始:
我有一个应用程序,可以使用 EKEventstore 将事件添加到用户的日历中。我曾经通过一个视图控制器完成这一切,包括选择用户日历之一的功能。我已经在代码中多次创建事件存储,一切正常。
现在我已经将我的应用程序升级为一些更专业的编码,包括几个视图控制器。一种是处理日历选择器(列出所有日历的简单表格视图),另一种负责创建新事件并将其保存到日历中。
EKEventstore 在 appdelegate.h 中声明
EKEventStore *es;
每个视图控制器在其 viewWillAppear 方法中定义 eventsstore:
es=[[EKEventStore alloc]init];
一切正常,我可以从 eventstore 加载事件并保护事件安全,但是一旦我切换到日历选择器视图控制器(只需加载它),然后返回到创建事件的视图控制器,应用程序崩溃。新发布后,我一切都恢复正常了。任何想法都受到高度赞赏。
这是异常抛出后的堆栈:
2011-08-25 15:35:18.795 Dutysheet Wx[13864:707] -[UINavigationButtonfresh]: 无法识别的选择器发送到实例 0x688f0a0 2011-08-25 15:35:18.822 Dutysheet Wx[13864:707] * 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[UINavigationButton 刷新]:无法识别的选择器发送到实例 0x688f0a0” *第一次抛出时的调用堆栈: ( 0 CoreFoundation 0x30b1364f 异常预处理 + 114 1 libobjc.A.dylib 0x3462ec5d objc_异常_抛出 + 24 2 CoreFoundation 0x30b171bf -[NSObject(NSObject) doesNotRecognizeSelector:] + 102 3 CoreFoundation 0x30b16649 __转发 + 508 4 核心基础 0x30a8d180 _CF_forwarding_prep_0 + 48 5 EventKit 0x339bfe1b -[EKEventStore _databaseChangedExternally] + 682 6 EventKit 0x339bf49f 数据库更改 + 18 7 CoreFoundation 0x30ae2d69 CFNotificationCenterDarwinCallBack + 24 8 核心基础 0x30adfbdf __CFMachPortPerform + 210 9 CoreFoundation 0x30aeaa97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 26 10 核心基础 0x30aec83f __CFRunLoopDoSource1 + 166 11 核心基础 0x30aed60d __CFRunLoopRun + 520 12 核心基础 0x30a7dec3 CFRunLoopRunSpecific + 230 13 核心基础 0x30a7ddcb CFRunLoopRunInMode + 58 14 图形服务 0x303fc41f GSEventRunModal + 114 15 图形服务 0x303fc4cb GSEventRun + 62 16 UIKit 0x30ba3d69-[UIApplication_run] + 404 17 UIKit 0x30ba1807 UIApplicationMain + 670 18 任务表 Wx 0x00002a83 主 + 82 19 任务表 Wx 0x000029f8 开始 + 52 ) 抛出“NSException”实例后调用终止
I'm new here but I've been reading along a lot. Mostely I found what I was looking for but now I'm stuck. Reading documentation and asking google didn't help so here I go:
I have an app that adds events to the user's calendar using EKEventstore. I used to do this all from one single view controller, including the function to pick one of the user's calendars. I've been creating eventstores several times in the code, and everything worked fine.
Now I've upgraded my app to some more professional coding, including several view controllers. One is handling the calendar picker (simple table view listing all calendars), another one does the creation and saving of new events to the calendar.
The EKEvenstore is declared in the appdelegate.h
EKEventStore *es;
Each view controller defines the evenststore in it's viewWillAppear method:
es=[[EKEventStore alloc]init];
Everything works fine, I can load and safe events from and to the eventstore, but as soon as I switch to the calendar picker view controller (just loading it up), and then going back to the view controller that creates events, the app crashes. After a new launch I everything is fine again. Any Idea is highly appreciated.
Here's my stack after the exception throw:
2011-08-25 15:35:18.795 Dutysheet Wx[13864:707] -[UINavigationButton refresh]: unrecognized selector sent to instance 0x688f0a0
2011-08-25 15:35:18.822 Dutysheet Wx[13864:707] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationButton refresh]: unrecognized selector sent to instance 0x688f0a0'
* Call stack at first throw:
(
0 CoreFoundation 0x30b1364f exceptionPreprocess + 114
1 libobjc.A.dylib 0x3462ec5d objc_exception_throw + 24
2 CoreFoundation 0x30b171bf -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
3 CoreFoundation 0x30b16649 __forwarding + 508
4 CoreFoundation 0x30a8d180 _CF_forwarding_prep_0 + 48
5 EventKit 0x339bfe1b -[EKEventStore _databaseChangedExternally] + 682
6 EventKit 0x339bf49f DatabaseChanged + 18
7 CoreFoundation 0x30ae2d69 CFNotificationCenterDarwinCallBack + 24
8 CoreFoundation 0x30adfbdf __CFMachPortPerform + 210
9 CoreFoundation 0x30aeaa97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 26
10 CoreFoundation 0x30aec83f __CFRunLoopDoSource1 + 166
11 CoreFoundation 0x30aed60d __CFRunLoopRun + 520
12 CoreFoundation 0x30a7dec3 CFRunLoopRunSpecific + 230
13 CoreFoundation 0x30a7ddcb CFRunLoopRunInMode + 58
14 GraphicsServices 0x303fc41f GSEventRunModal + 114
15 GraphicsServices 0x303fc4cb GSEventRun + 62
16 UIKit 0x30ba3d69 -[UIApplication _run] + 404
17 UIKit 0x30ba1807 UIApplicationMain + 670
18 Dutysheet Wx 0x00002a83 main + 82
19 Dutysheet Wx 0x000029f8 start + 52
)
terminate called after throwing an instance of 'NSException'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论