I'm learning swift and caught in a situation:
I have a function which returns array. This function calls another closure inside and I want to pass the closure result as return to the function.
This is how my code has been setup
func setData() -> [City] {
let conn = ApiConnection()
conn.get_cities{ citiesList in
return (citiesList)
}
}
When I do this I get error saying "Cannot convert return expression of type '()' to return type 'City?'"
Please advice how I can return the citiesList to my function