简体   繁体   English

如何在Swift中访问iCalendar中的事件?

[英]How to access the events in iCalendar in Swift?

I am learning Swift and trying to access the the events in iCalendar via EventKit . 我正在学习Swift并尝试通过EventKit访问iCalendar的事件。

In Objective-C, it works like this: 在Objective-C中,它的工作方式如下:

[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {

    }];

In Swift from the document: 在Swift中从文档中:

eventStore.requestAccessToEntityType(entityType: EKEntityType>, **completion: EKEventStoreRequestAccessCompletionHandler! )** eventStore.requestAccessToEntityType(entityType:EKEntityType>,**完成:EKEventStoreRequestAccessCompletionHandler! )**

What is " completion:EKEventStoreRequestAccessCompletionHandler " and what should I put in here? 什么是“ 完成:EKEventStoreRequestAccessCompletionHandler ”,我应该在这里输入什么?

⌘单击EKEventStoreRequestAccessCompletionHandler (或任何未知类型),Xcode将跳至其定义:

typealias EKEventStoreRequestAccessCompletionHandler = (Bool, NSError!) -> Void

this is how it works :) 这是如何工作的:)

eventStore.requestAccessToEntityType(EKEntityTypeEvent) {
        (success: Bool, error: NSError!) in
        println("Got permission = \(success); error = \(error)")
}

PS: need to import EventKitUI PS:需要导入EventKitUI

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM