Ich versuche, auf das Kontakte-Framework zuzugreifen, um einen neuen Kontakt im Adressbuch des Benutzers speichern zu können. Ich habe den folgenden Code ...Absturz beim Zugriff auf das Kontakte-Framework in iOS 10
import Contacts
import ContactsUI
an der Spitze der Datei und schließen ein Verfahren ...
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)
}
})
}
Auf der Linie markiert, gibt es eine SIABRT
Absturz. Wickeln des Stapels nach unten und po $arg1
läuft wirft die folgende up ...
error: Couldn't materialize: couldn't read the value of register x0
Errored out in Execute, couldn't PrepareToExecuteJITExpression
ich die notwendige Linie in Info.plist
im Stamm dict
<key>NSContactsUsageDescription</key>
<string>We need to access Contacts to import entries direct from the app.</string>
Ich habe auch enthalten Contacts.framework
und ContactsUI.framework
in ‚Linked Frameworks haben und Bibliotheken in den Zieleigenschaften (Allgemein)
Wird auf Ihrem Gerät iOS 10 ausgeführt? Reinigen des Projekts, Löschen der App vom Gerät oder Neustart manchmal hilft –
bitte überprüfen Sie diesen Link http://StackOverflow.com/Questions/14704310/error-couldnt-materialize-struct-Couldnt-Read-Steuer –
@Josip Ich habe versucht, zu deinstallieren vom Telefon, Neustart des Telefons, Neustart von XCode und Reinigung des Projekts, aber kein Glück :( – Brendan