iOS 10及更高版本中的EKEventStore requestAccessToEntityType崩溃应用程序

Max*_*Max 3 calendar ios ekevent ekeventstore swift

我有应用程序,我必须在默认日历中添加事件,直到iOS 10正常.现在在iOS 10中它不授予访问权限.我已经开始use legacy swift language versionyes.我的代码是

let eventStore = EKEventStore()
switch EKEventStore.authorizationStatusForEntityType(EKEntityType.Event) {
   case .Authorized:
            //access
   case .Denied:
            print("Access denied")
   case .NotDetermined:
       eventStore.requestAccessToEntityType(EKEntityType.Event, completion:
                {[weak self] (granted: Bool, error: NSError?) -> Void in
                    if granted {
                        //access
                    } else {
                        print("Access denied")
                    }
                })
   default:
            print("Case Default")
  }
Run Code Online (Sandbox Code Playgroud)

调试我的应用程序eventStore.requestAccessToEntityType在Xcode 8中崩溃.

调试截图

我的应用程序是实时的,我需要解决它.任何帮助都是适当的.提前致谢.

Leo*_*rdo 7

在iOS 10版本中,您需要在Info.plist上为权限警报设置描述消息

重要提示:iOS 10.0上或之后链接的iOS应用程序必须在其Info.plist文件中包含其需要访问的数据类型的使用说明密钥,否则将崩溃.要专门访问提醒和日历数据,它必须分别包括NSRemindersUsageDescription和NSCalendarsUsageDescription.

来自Apple Docs