作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试使用 CNContactStore
函数 requestAccessForEntityType
获得使用地址簿的授权,但收到一个我不明白的错误。
该函数在类中定义为:
public func requestAccessForEntityType(entityType: CNEntityType, completionHandler: (Bool, NSError?) -> Void)
这是我的代码:
let addressBookRef: CNContactStore = CNContactStore.requestAccessForEntityType(CNEntityType.Contacts, completionHandler: authorizationHandler)
func authorizationHandler(granted: Bool, error: NSError?) {
}
编译器错误:
Extra argument 'completionHandler' in call
最佳答案
事实证明,我是直接在类中定义属性的。显然你不能在那里运行一个函数,所以它不起作用。呃!
我需要做的就是放入类:
let addressBookRef = CNContactStore()
当真正需要请求许可时,以下内容是:
addressBookRef.requestAccessForEntityType(CNEntityType.Contacts, completionHandler: authorizationHandler)
关于swift - CNContactStore.requestAccessForEntityType 参数问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32527015/
我尝试使用下面的代码访问手机联系人,但系统不会提示用户授予我权限。 let store = CNContactStore() store.requestAccessForEntity
我尝试使用 CNContactStore 函数 requestAccessForEntityType 获得使用地址簿的授权,但收到一个我不明白的错误。 该函数在类中定义为: public func r
我是一名优秀的程序员,十分优秀!