I am trying to set reminder and need to access request to entity type method in Swift 2.0 for iOS9. However, it gives me the error:
Use of unresolved identifier
@IBAction func setReminder(sender: AnyObject) {
appDelegate = UIApplication.sharedApplication().delegate
as? AppDelegate
if appDelegate!.eventStore == nil {
appDelegate!.eventStore = EKEventStore()
appDelegate!.eventStore!.requestAccessToEntityType(EKEntityTypeReminder, completion: {(granted, error) in //use of unresolved identifier EKEntityTypeReminder
if !granted {
println("Access to store not granted")
println(error.localizedDescription)
} else {
println("Access granted")
}
})
}
if (appDelegate!.eventStore != nil) {
self.createReminder()
}
}
This code works for Swift, but not Swift 2. Did anybody have this type of issue?
EKEntityType
is now an enum
, which contains two types one could specify.
For EKEntityTypeReminder
:
appDelegate!.eventStore!.requestAccessToEntityType(EKEntityType.Reminder, completion:
{(granted, error) in
if !granted
{
println("Access to store not granted")
println(error.localizedDescription)
}
else
{
println("Access granted")
}
})
Or simply just:
.Reminder