Created
October 13, 2016 10:09
-
-
Save ahikmatf/2542f720feb854417d5e4d600137afc6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/a/28800828/5552518 | |
import Foundation | |
import Alamofire | |
class ParallelServiceCaller { | |
var firstServiceCallComplete = false | |
var secondServiceCallComplete = false | |
func startServiceCalls() { | |
let firstRequest = Alamofire.request(.GET, "http://httpbin.org/get", parameters: ["first": "request"]) | |
firstRequest.responseString { request, response, dataString, error in | |
self.firstServiceCallComplete = true | |
self.handleServiceCallCompletion() | |
} | |
let secondRequest = Alamofire.request(.GET, "http://httpbin.org/get", parameters: ["second": "request"]) | |
secondRequest.responseString { request, response, dataString, error in | |
self.secondServiceCallComplete = true | |
self.handleServiceCallCompletion() | |
} | |
} | |
private func handleServiceCallCompletion() { | |
if self.firstServiceCallComplete && self.secondServiceCallComplete { | |
// Handle the fact that you're finished | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment