Created
December 10, 2016 17:11
-
-
Save alfian0/68c2561a6c54cfaf723228e0cce54083 to your computer and use it in GitHub Desktop.
Just Simple Merging API Call in Swift
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 mergeAPICall() { | |
let group = dispatch_group_create() | |
dispatch_group_enter(group) | |
/*** | |
Call your method for each endpoint after dispatch_group_enter(group) | |
*/ | |
func fetchEventList(success: { (eventList) in | |
/*** | |
Add dispatch_group_leave(group) if API Call return success or error | |
*/ | |
dispatch_group_leave(group) | |
}) { (error) in | |
dispatch_group_leave(group) | |
} | |
func fetcMovieList(success: { (eventList) in | |
/*** | |
Add dispatch_group_leave(group) if API Call return success or error | |
*/ | |
dispatch_group_leave(group) | |
}) { (error) in | |
dispatch_group_leave(group) | |
} | |
dispatch_group_notify(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)) { | |
dispatch_async(dispatch_get_main_queue(), { | |
/*** | |
Do something if All API Call done | |
Your code Here | |
*/ | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment