This crash only happens on iOS 11, I have no idea how to fix it.
The crash happens when tapping on the [Show All] button on the new toolbar for iOS 11's EKCalendarChooser class, but while it's selectionStyle set to .single
:
Fatal Exception: NSInternalInconsistencyException Invalid style
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x1830e3d38 __exceptionPreprocess
1 libobjc.A.dylib 0x1825f8528 objc_exception_throw
2 CoreFoundation 0x1830e3c0c +[NSException raise:format:]
3 Foundation 0x183a72c24 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
4 EventKitUI 0x1941ad908 -[EKCalendarChooser _selectAllCalendarsAndStores:]
5 EventKitUI 0x1941a6384 -[EKCalendarChooser showAllButtonPressed]
6 UIKit 0x18c52820c -[UIApplication sendAction:to:from:forEvent:]
7 UIKit 0x18c68253c -[UIBarButtonItem(UIInternal) _sendAction:withEvent:]
8 UIKit 0x18c52820c -[UIApplication sendAction:to:from:forEvent:]
9 UIKit 0x18c52818c -[UIControl sendAction:to:forEvent:]
10 UIKit 0x18c512f4c -[UIControl _sendActionsForEvents:withEvent:]
11 UIKit 0x18c5130b4 -[UIControl _sendActionsForEvents:withEvent:]
12 UIKit 0x18c527a80 -[UIControl touchesEnded:withEvent:]
13 UIKit 0x18cb73ec8 _UIGestureEnvironmentSortAndSendDelayedTouches
14 UIKit 0x18cb6f488 _UIGestureEnvironmentUpdate
15 CoreFoundation 0x18308b8b8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
16 CoreFoundation 0x183089270 __CFRunLoopDoObservers
17 CoreFoundation 0x18308982c __CFRunLoopRun
18 CoreFoundation 0x182faa2d8 CFRunLoopRunSpecific
19 GraphicsServices 0x184e3bf84 GSEventRunModal
20 UIKit 0x18c557880 UIApplicationMain
21 MyApp1 0x104d92be4 main (AppDelegate.swift:15)
22 libdyld.dylib 0x182ace56c start
I wonder is there a way to hide the new toolbar?
===== Edited on 19 Nov 2017
Screenshot added to show the new toolbar:
Once the selectedCalendars
is left empty, the new toolbar is showing. Once the button [Show All] taps, the crash occurs.
I have encountered the same error and discovered a strange but surprisingly effective method of solving it. Turns out if you clear out the selected calendars set before presenting the view controller the toolbar disappears, thus protecting from the crash.
calendarChooser.selectedCalendars = Set();