首页 文章

尝试访问日历时出错“使用未解析的标识符'EKEntityTypeEvent'”

提问于
浏览
1

我通过EventKit使用Swift 2进行日历 . 在网上挖掘时,我发现few examples在另一个SO question上显示了与此answer类似的实现 .

我一直打的错误是

使用未解析的标识符'EKEntityTypeEvent'

在我的viewDidLoad()中 -

let eventStore = EKEventStore()

switch EKEventStore.authorizationStatusForEntityType(EKEntityTypeEvent) {        
case .Authorized:
    insertEvent(eventStore)
case .Denied:
    print("Access denied")
case .NotDetermined:
    eventStore.requestAccessToEntityType(EKEntityTypeEvent, completion:
        {[weak self] (granted: Bool, error: NSError!) -> Void in
            if granted {
                self!.insertEvent(eventStore)
            } else {
                print("Access denied")
            }
        })
default:
    print("Case Default")
}

有关此错误的任何想法?

我正在运行El Capitan / XCode 7 Beta 3 .

1 回答

  • 7

    好的,这里主要有两个错误 - 第一个已在评论中讨论过 .

    第一:使用 .EventEKEntityType.Event 而不是 EKEntityTypeEvent .

    第二:更改完成处理程序的声明以接受 NSError? 而不是 NSError! ,因为the actual completion handler是以这种方式定义的 .

相关问题