尝试访问日历时出错 "Use of unresolved identifier 'EKEntityTypeEvent'"

Error "Use of unresolved identifier 'EKEntityTypeEvent'" trying to access Calendar

我正在尝试使用 Swift 通过 EventKit 访问用户的日历 2. 在网上搜索时,我发现了 few examples showing similar implementations to this answer on another SO question.

我一直遇到的错误是

Use of unresolved identifier 'EKEntityTypeEvent'

在我看来DidLoad() -

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.

好吧,这里主要有两点不对——第一点已经在评论中讨论过了。

首先:使用.EventEKEntityType.Event代替EKEntityTypeEvent

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