我试图通过在iOS8中使用 Swift使用EKEventStore获取事件列表,据我所知,文档尚未更新. 这就是我想要做的: let eventStore = EKEventStore()eventStore.requestAccessToEntityType(EKEntityType(), EKEventStoreRequestAc
这就是我想要做的:
let eventStore = EKEventStore() eventStore.requestAccessToEntityType(EKEntityType(), EKEventStoreRequestAccessCompletionHandler(Bool(), NSError(){}))
这是我得到的错误:
‘EKEventStoreRequestAccessCompletionHandler’不能用'(Bool,NSError)构造
你知道如何在Swift中正确使用方法或处理程序吗?
请试试这个:func handler(granted: Bool, error: NSError!) { // put your handler code here } @IBAction func click(sender: AnyObject) { let eventStore = EKEventStore() // 'EKEntityTypeReminder' or 'EKEntityTypeEvent' eventStore.requestAccessToEntityType(EKEntityTypeEvent, completion: handler) }
另一个变种是:
@IBAction func click(sender: AnyObject) { let eventStore = EKEventStore() // 'EKEntityTypeReminder' or 'EKEntityTypeEvent' eventStore.requestAccessToEntityType(EKEntityTypeEvent, completion: { granted, error in // put your handler code here }) }