如何在Swift iOS 8中使用requestAccessToEntityType方法

如何在Swift iOS 8中使用requestAccessToEntityType方法,第1张

概述我试图通过在iOS8中使用 Swift使用EKEventStore获取事件列表,据我所知,文档尚未更新. 这就是我想要做的: let eventStore = EKEventStore()eventStore.requestAccessToEntityType(EKEntityType(), EKEventStoreRequestAccessCompletionHandler(Bool(), @H_404_2@ 我试图通过在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        })}
@H_404_2@ 总结

以上是内存溢出为你收集整理的如何在Swift iOS 8中使用requestAccessToEntityType方法全部内容,希望文章能够帮你解决如何在Swift iOS 8中使用requestAccessToEntityType方法所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1005769.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存