在EKEventStore-Swift中创建EKCalendar

在EKEventStore-Swift中创建EKCalendar,swift,ios8,eventkit,ekeventstore,Swift,Ios8,Eventkit,Ekeventstore,当my app首次运行时,我正在尝试在EKEventStore中创建一个日历。我发现,但我对Objective-C的了解还不够,无法将其转换为Swift,而且根据我所做的研究,我想知道这种方法在ios8中是否仍然可行 试试(注意这是一种提醒类型,但如果需要,您可以更改类型): 您需要检查授权: func verifyUserEventAuthorization() { switch EKEventStore.authorizationStatusForEntityType(EKE

当my app首次运行时,我正在尝试在EKEventStore中创建一个日历。我发现,但我对Objective-C的了解还不够,无法将其转换为Swift,而且根据我所做的研究,我想知道这种方法在ios8中是否仍然可行

试试(注意这是一种提醒类型,但如果需要,您可以更改类型):

您需要检查授权:

    func verifyUserEventAuthorization() {
    switch EKEventStore.authorizationStatusForEntityType(EKEntityTypeReminder) {
    case .Authorized:
        ...
    case .Denied:
        ...
    case .NotDetermined:
        eventStore.requestAccessToEntityType(EKEntityTypeReminder, completion:
            { [weak self](granted: Bool, error: NSError!) -> Void in
                if granted {
                    ...
                }
                else {
                   ...
                }
        })
    case .Restricted:
        ...
    }
}
    func verifyUserEventAuthorization() {
    switch EKEventStore.authorizationStatusForEntityType(EKEntityTypeReminder) {
    case .Authorized:
        ...
    case .Denied:
        ...
    case .NotDetermined:
        eventStore.requestAccessToEntityType(EKEntityTypeReminder, completion:
            { [weak self](granted: Bool, error: NSError!) -> Void in
                if granted {
                    ...
                }
                else {
                   ...
                }
        })
    case .Restricted:
        ...
    }
}