IOS application error: I screwed the date calculation somewhere

My application accidentally crashes, I can’t create the same case that occurs in user devices, here is more detailed information from the crash report:

CLASS failed:

NSInternalInconsistencyException 

FUNCTION:

 -[CalendarViewController deleteEvent:] 

The implementation of the method is as follows:

  -(void) deleteEvent: (EKSpan ) span :(EKEvent *) eventToDelete{ NSError* error = nil; [sharedEventStore removeEvent:eventToDelete span:span error:&error]; // refresh the UI } 

Stacktrace:

 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 

Note that I use a single instance of EKEventStore in a singleton pattern:

 // 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); } 

Any possible reason for this failure?

+6
source share
1 answer

This is definitely a mistake. You can disable the iPad iPad application with the following:

  • Create an event repeating every day with repeating. A few days to the future.
  • Change the location of the second occurrence and save it for all future events.
  • Delete the first occurrence and select only this event. Bam!

This does not happen when the location change starts from appearing after the second OR, when all future events have been selected. When you take steps in the code, your application crashes with the wounderful "I messed up ..."

Brief work:

 [eventStore removeEvent:firstEvent span:(firstEvent.isDetached ? EKSpanFutureEvents : desiredSpan) commit:YES error:nil]; 
+8
source

All Articles