These answers were written as long as I am right. There is one way: with a handler check, get the result and use it at your point.
enum Errors: Error {
case noData
case unknownError
}
func progress(data: String?, completionHandler: @escaping (_ result: String? , _ error: Error?) -> Void ) {
guard let data = data else {
throw nil, Errors.noData
}
result = data
return result, nil
}
process(data: "A data to process"){(result, error) -> Void in
}
source
share