-2

I want to present a view Controller after the user Authenticates with Touch ID, here is my code and the error i am getting, I have no idea how to solve itenter image description here

and the console Shows enter image description here

Sumit Dhariwal
  • 577
  • 3
  • 15
  • The error clearly states that you are trying to do something that should be done on main thread only. The closure in which you are trying to present your VC must be running on a thread other than main thread, hence the error. You need to get hold of main thread before preseting your VC. – Puneet Sharma Nov 08 '17 at 05:01
  • any idea how to do it? – Gerardo Torres Nov 08 '17 at 05:04
  • 1
    You can use [GCD](https://stackoverflow.com/questions/24985716/in-swift-how-to-call-method-with-parameters-on-gcd-main-thread) or [OperationQueue](https://developer.apple.com/documentation/foundation/operationqueue) – Puneet Sharma Nov 08 '17 at 05:06
  • 1
    Thanks a lot! it has finally worked with OperationQueue.main.addOperation, Thanks!!!!!! – Gerardo Torres Nov 08 '17 at 05:08

1 Answers1

0

Looks like you need to access main thread.try this.

For Swift 2.3

dispatch_async(dispatch_get_main_queue()) { 
    //place your code to push viewController
}

For Swift 3

DispatchQueue.main.async {
    //place your code to push viewController
}
Sumit Dhariwal
  • 577
  • 3
  • 15