Reputation: 967
I tried to request access to the calendar using following code:
EKEventStore().requestAccess(to: EKEntityType.event, completion: {
(success: Bool, error: NSError!) in
print("Got permission = \(success); error = \(error)")
})
Xcode wants to add as! EKEventStoreRequestAccessCompletionHandler
because it says
Cannot convet value of type (Bool, NSError!) ...".
But when I add this the app crashes with EXC_BAD_INSTRUCTION and no further explanation. Any ideas whats wrong here?
Thanks a lot
Upvotes: 0
Views: 842
Reputation: 72410
In Swift 3 you need to use Error
instead of NSError
check Apple documentation for more detail.
EKEventStore().requestAccess(to: EKEntityType.event, completion: {
(success: Bool, error: Error?) in
print("Got permission = \(success); error = \(error)")
})
Upvotes: 6