I am trying to return a value from a function after executing a function that is not finishing immediately.
for example:
func returnSomeValue() -> String {
let group = DispatchGroup()
group.enter()
service.longTimeTofinish(onFinish: { group.leave() } ) // <-- this function takes long time to finish
group.notify(queue: .main) {
return "Returning some value as example" // <-- Here is the issue
}
}
The compiler is showing an error "Cannot convert value of type 'String' to closure result type Void". The closure inside notify can't return value to my outer function. Any ideas how to solve this issue?