我试图通过在iOS8中使用
Swift使用EKEventStore获取事件列表,据我所知,文档尚未更新.
这就是我想要做的:
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 }) }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。