Inside my app, I do few requests to my back-end. In one case I have a function that should return two parameters (may be Bool
and Bool
for example). But there comes my problem. To return those two parameters, I need to receive some info from back-end first, so it would look like this (will be written in pseudo-swift-code):
func request() -> (Bool, Bool) {
var one: Bool?
var two: Bool?
Alamofire.request(url1).response { (response) in
if let response = response { one = response }
}
Alamofire.request(url2).response { (response) in
if let response = response { two = response }
}
if let one = one, let two = two {
return (one, two)
}
return (nil, nil)
}
How do I achieve a function that waits for those two web requests?