Reputation: 15666
import EventKit
var store = EKEventStore()
store.requestAccessToEntityType(EKEntityTypeEvent) {
(success: Bool, error: NSError!) in
println("Got permission = \(success); error = \(error)")
}
I have the above code in a Playground and the response is...
Got permission = false; error = nil
How can I give permission to Playground?
Upvotes: 2
Views: 1219
Reputation: 36
You can do this now. I tried it in Xcode 8.3.2 on macOS in a playground. The code needs to be updated like so:
import EventKit
var store = EKEventStore()
store.requestAccess(to: .event, completion: {
(success, error) -> Void in
print("Got permission = \(success); error = \(error)")
})
I get a request for permission to access the calendar. The output for me is:
Got permission = true; error = nil
Upvotes: 0
Reputation: 7513
Playgrounds don't support entitlements, which are required to access calendars/reminders.
It's a real shame, as this would be a perfect way to play around with how you would like to use an API.
Upvotes: 3