I'm trying to get access to a user's calendars via EventKit using Swift 2. In digging around online, I've found a few examples showing similar implementations to this answer on another SO question.
The error I keep hitting is
Use of unresolved identifier 'EKEntityTypeEvent'
In my 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")
}
Any ideas on this error?
I'm running El Capitan / XCode 7 Beta 3.
Okay, there are mainly two things wrong here - the first has already been discussed in the comments.
First: use .Event
or EKEntityType.Event
instead of the EKEntityTypeEvent
.
Second: change the declaration of the completion handler to accept a NSError?
instead of NSError!
because the actual completion handler is defined this way.