Last active
April 7, 2016 15:15
-
-
Save arvindhsukumar/fb03265426e10a93e4e5612b9875f607 to your computer and use it in GitHub Desktop.
Introduction to dispatch_group
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
func asyncFunctionA(){ | |
let urlRequest: NSURLRequest = ... | |
let task = self.session?.dataTaskWithRequest(urlRequest, completionHandler: { | |
(data:NSData?, response:NSURLResponse?, error:NSError?) in | |
self.taskAComplete = true | |
self.checkResults() | |
}) | |
} | |
func asyncFunctionB(){ | |
let urlRequest: NSURLRequest = ... | |
let task = self.session?.dataTaskWithRequest(urlRequest, completionHandler: { | |
(data:NSData?, response:NSURLResponse?, error:NSError?) in | |
self.taskBComplete = true | |
self.checkResults() | |
}) | |
} | |
func checkResults(){ | |
// Why does this function have to be called twice?! | |
if taskAComplete && taskBComplete { | |
//Handle Result | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment