2017-11-01 2 views
3

次のコードを実行して、メモ帳アプリケーションに複数のカレンダーを選択できるようにします。 iOS 10.3.1までは問題ありませんでした。 11.0.2では、まだ活動的なデバイスで作業していました。ただし、11.1以降、次のエラーでクラッシュします。iOS11.1でEKCalendarChooserがクラッシュする

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKeyedSubscript:]: key cannot be nil' 

コードは以下のとおりです。基本的に空白のカレンダーチューザーを開いています。

if (_eventStore == nil) { 
    _eventStore = [[EKEventStore alloc] init]; 
} 
// the selector is available, so we must be on iOS 6 or newer 
[_eventStore requestAccessToEntityType:EKEntityTypeEvent 
          completion:^(BOOL granted, NSError *error) { 
           dispatch_async(dispatch_get_main_queue(), ^{ 
            if (error) 
            { 
             // display error message here 
            } 
            else if (!granted) 
            { 
             // display access denied error message here 
            } 
            else 
            { 
             // access granted 

             EKCalendarChooser *calendarChooser = [[EKCalendarChooser alloc] 
                      initWithSelectionStyle:EKCalendarChooserSelectionStyleMultiple 
                      displayStyle:EKCalendarChooserDisplayAllCalendars 
                      eventStore:_eventStore]; 

             calendarChooser.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
             calendarChooser.delegate = self; 
             calendarChooser.showsCancelButton = YES; 
             calendarChooser.showsDoneButton = YES; 


              NSSet *calendarSet = [[NSSet alloc] init]; 
              calendarChooser.selectedCalendars = calendarSet; 


             UINavigationController *sub = [[UINavigationController alloc] initWithRootViewController:calendarChooser]; 
             sub.navigationBar.barStyle = UIBarStyleDefault; 
             sub.toolbar.barStyle = UIBarStyleDefault; 
             [self presentViewController:sub animated:YES completion:nil]; 
             //ios11 crashes after this 
            } 
           }); 
          }]; 

ありがとうございました。

答えて

4

EKCalendarChooserDisplayAllCalendarsがクラッシュを引き起こしていたことが判明しました。理想的ではありませんが、iOSが11.1以上の場合、クラッシュを避けることができます。

         EKCalendarChooserDisplayStyle displayStyle = EKCalendarChooserDisplayAllCalendars; 
             if (@available(iOS 11.1, *)) { 
              displayStyle = EKCalendarChooserDisplayWritableCalendarsOnly; 
             } 
             EKCalendarChooser *calendarChooser = [[EKCalendarChooser alloc] 
                      initWithSelectionStyle:EKCalendarChooserSelectionStyleMultiple 
                      displayStyle:displayStyle 
                      eventStore:eventStore]; 
+0

同じ問題があります。書き込み可能なカレンダーにしかアクセスできない場合、これは本当に悪いことです。 –

+0

はい、絶対にひどいです。少なくともアップルは問題があると認めている。 (EventKitからEKCalendarChooserを初期化するとアプリケーションがクラッシュすることがある(34608102))https://developer.apple.com/library/content/releasenotes/General/RN-iOS-11.1/index.html#//apple_ref/doc/uid/TP40017683-CH1-SW1 – yoshitech

+0

この週末に別のバグが見つかりました。秋の時間変更中に午前1時から午前2時の間の開始時刻と終了時刻を持つEKEventを保存すると、時刻が午前1時から午前2時までの2番目の時刻になると、データベースは1時間を終了時刻(ただし開始時刻ではない)から減算します。終了後に開始するイベントが発生します。私はバグレポートを提出しましたが、誰かがこのバグを複製できるかどうか不思議です。両方の日付がロケールの日付形式を使用して同じ形式になるため、生データを照会する必要があることに注意してください。 –

関連する問題