6

我的应用程序随机崩溃,我无法生成与用户设备中发生的相同情况,此处提供了崩溃报告中的更多详细信息:

碰撞等级:

NSInternalInconsistencyException

功能:

-[CalendarViewController deleteEvent:] 

方法实现是这样的:

  -(void) deleteEvent: (EKSpan ) span :(EKEvent *) eventToDelete{

    NSError* error = nil;

    [sharedEventStore removeEvent:eventToDelete span:span error:&error];

   // refresh the UI   
}

堆栈跟踪:

0 CoreFoundation 0x33acf2a3 <redacted> + 162
1 libobjc.A.dylib 0x3b7ec97f objc_exception_throw + 30
2 CoreFoundation 0x33acf15d <redacted> + 0
3 Foundation 0x343a4ab7 <redacted> + 90
4 EventKit 0x34208b33 <redacted> + 1642
5 EventKit 0x342084c1 <redacted> + 408
6 EventKit 0x342091f7 <redacted> + 306
7 EventKit 0x341fa199 <redacted> + 144
8 EventKit 0x341fa0ff <redacted> + 30
9 Calendar 0x0010acaf -[CalendarViewController deleteEvent:] + 126
10 Calendar 0x0016f585 -[BlockAlertView dismissWithClickedButtonIndex:animated:] + 196
11 UIKit 0x359c20c5 <redacted> + 72
12 UIKit 0x359c2077 <redacted> + 30
13 UIKit 0x359c2055 <redacted> + 44
14 UIKit 0x359c190b <redacted> + 502
15 UIKit 0x359c1e01 <redacted> + 488
16 UIKit 0x358ea5f1 <redacted> + 524
17 UIKit 0x358d7801 <redacted> + 380
18 UIKit 0x358d711b <redacted> + 6154
19 GraphicsServices 0x375ed5a3 <redacted> + 590
20 GraphicsServices 0x375ed1d3 <redacted> + 34
21 CoreFoundation 0x33aa4173 <redacted> + 34
22 CoreFoundation 0x33aa4117 <redacted> + 138
23 CoreFoundation 0x33aa2f99 <redacted> + 1384
24 CoreFoundation 0x33a15ebd CFRunLoopRunSpecific + 356
25 CoreFoundation 0x33a15d49 CFRunLoopRunInMode + 104
26 GraphicsServices 0x375ec2eb GSEventRunModal + 74
27 UIKit 0x3592b301 UIApplicationMain + 1120
28 Calendar 0x000f9533 main + 66
29 Calendar 0x0008a6a8 start + 40 

请注意,我在单例模式中使用 EKEventStore 的一个实例:

// this is in separate class

static EKEventStore *eventStore = nil;

    + (EKEventStore *)getEventStoreInstance
    {

        if (eventStore == nil){
            @synchronized(self){
                if (eventStore == nil){
                    eventStore = [[EKEventStore alloc] init];
                }
            }
        }

        return(eventStore);
    }

这次崩溃有什么可能的原因吗?

4

1 回答 1

8

这绝对是一个错误。您可以使用以下命令使 iPad 的日历应用程序崩溃:

  1. 创建一个事件,每天重复一次,并在未来几天重复出现。
  2. 更改第二次出现的位置并将其保存以供将来所有事件使用。
  3. 删除第一个事件并仅选择此事件。砰!

这不会发生,当位置更改开始于第二次之后的发生或选择删除所有未来事件时。当您执行代码中的步骤时,您的应用程序会因“我搞砸了......”而崩溃

一个简短的解决方法是:

[eventStore removeEvent:firstEvent span:(firstEvent.isDetached ? EKSpanFutureEvents : desiredSpan) commit:YES error:nil];
于 2013-05-22T12:08:14.193 回答