2

Currently, I have the following code in place.

if localAuthenticationContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &authError) {
        
        localAuthenticationContext.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reasonString) { success, evaluateError in
            
            if success {
                self.performSegue(withIdentifier: "settingChange", sender: self)                    //TODO: User authenticated successfully, take appropriate action

The code performs a segue, to another view Controller if the touch id is correctly authenticated, however when I try out the code I get this error:

enter image description here

I have tried the code without using the TouchID, and it works fine but I don't know why it produces the error upon the TouchID use. Can someone help?

Community
  • 1
  • 1
Arnav GUPTA
  • 295
  • 1
  • 2
  • 17
  • Do you have an error message in console? Like main thread stuff? Because `performSegue()` is related to UI and has to be done in main thread. Also, it's saying `evaluatePolicy()` states: `A closure that is executed when policy evaluation finishes. This is evaluated on a private queue internal to the framework in an unspecified threading context.` – Larme Feb 13 '18 at 15:14

1 Answers1

1

There may be an issue with performSegue operation. All UI changes related operations must be performed in main queue. Use DispatchQueue with main.

Try this and see (Note: I've solution in Swift 4):

if success {

  DispatchQueue.main.async(execute: {
     self.performSegue(withIdentifier: "settingChange", sender: self)
  })

}
Krunal
  • 77,632
  • 48
  • 245
  • 261