我正在尝试访问联系人框架,因此我可以将新联系人保存到用户地址簿中。我有以下代码...尝试访问iOS 10中的联系人框架时发生崩溃
import Contacts
import ContactsUI
在文件的头部和包括方法,...
func requestForAccess(completion: (granted: Bool) ->()) {
dispatch_async(dispatch_get_global_queue(Int(QOS_CLASS_BACKGROUND.rawValue), 0), {
let authStatus = CNContactStore.authorizationStatusForEntityType(.Contacts)
switch authStatus {
case .Authorized:
completion(granted: true)
case .Denied, .NotDetermined:
// CRASH HERE before the completion block is called, after calling
// requestAccessForEntityType
self.contactStore.requestAccessForEntityType(.Contacts, completionHandler: { (access, accessError) ->() in
if access {
completion(granted: access)
} else {
if authStatus == .Denied {
dispatch_async(dispatch_get_main_queue(), {() ->() in
let msg = "\(accessError!.localizedDescription)\n\nPlease allow the app to access your contacts through the Settings."
//self.alertService.showAlert(msg)
})
}
}
})
default:
completion(granted: false)
}
})
}
在标线,还有一个SIABRT
崩溃。蜿蜒起伏的堆栈和运行po $arg1
抛出了以下...
error: Couldn't materialize: couldn't read the value of register x0
Errored out in Execute, couldn't PrepareToExecuteJITExpression
我有必要的线Info.plist
根dict
<key>NSContactsUsageDescription</key>
<string>We need to access Contacts to import entries direct from the app.</string>
我也包括在“链接的框架Contacts.framework
和ContactsUI.framework
和库'在目标属性(一般)
您的设备是否运行iOS 10?清理项目,从设备删除应用程序或重新启动有时帮助 –
请检查此链接http://stackoverflow.com/questions/14704310/error-couldnt-materialize-struct-couldnt-read-eax –
@josip我试过卸载从手机,重新启动手机,重新启动XCode和清理项目,但没有运气:( – Brendan