The function below checks whether protected data is available.
func isProtectedDataAvailable(_ completion: ((_ isProtectedDataAvailable: Bool)->Void)?) {
DispatchQueue.main.async {
completion?(UIApplication.shared.isProtectedDataAvailable)
}
}
How can I change the function so that it can be called even when the main thread is paused in a setting like this:
let dispatch = DispatchGroup()
dispatch.enter()
isProtectedDataAvailable { isProtectedDataAvailable in
//...
dispatch.leave()
}
dispatch.wait()
The wait()
above would pause the main queue and the completion handler would never be called.