In a variable which is used for a table view data source array controller, I'm trying to get a value with a asynchronous function:
dynamic var price: Double {
get {
if id == "EUR" {
PriceQuery.shared.loadprice("JPY") { price in
return price
}
}
return 0.0
}
}
I'm getting the error: "unexpected non-void return value in a void function". Although it makes sense that the downer return 0.0
doesn´t "know" it has to "wait" for the upper asynchronous return, I don´t know how I could solve the problem.
There is already an answer about how to return asynchronously in a function. But I can't use a completion handler inside a variable, right?