0

enter image description here

DispatchQueue.main.async {
}

This cause error in my Extension enter image description here

How I use it

 let topController = UIApplication.shared.topMostViewController()
9to5ios
  • 5,319
  • 2
  • 37
  • 65

1 Answers1

1

You can try to like below

DispatchQueue.main.async {
    let topController = UIApplication.shared.topMostViewController()
}

or alternatively you can use block. You can’t return directly from async operation.

func topMostViewController(onSuccess: (UIViewController) -> ()) {

...
}
Arasuvel
  • 2,971
  • 1
  • 25
  • 40