如何在 Swift 2.0 iOS 9 中使用 requestAccessToEntityType 方法?

How to requestAccessToEntityType method in Swift 2.0 iOS 9?

我正在尝试设置提醒,需要访问 Swift 2.0 中 iOS9 实体类型方法的请求。但是,它给了我错误:

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()
    }
}

此代码适用于 Swift,但不适用于 Swift 2. 有人遇到过此类问题吗?

EKEntityType 现在是 enum,其中包含两种可以指定的类型。

对于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")
    }
})

或者只是:

.Reminder