Created
January 26, 2016 06:58
-
-
Save scottdelly/ba739014d0052dfb0300 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
let contactsGroup = dispatch_group_create() | |
dispatch_group_enter(contactsGroup) //Enter group for the first time | |
loadContactsFromServerAPIWithCompletion({ (contacts:[User]) -> () in | |
doStuffWithContacts(contacts) | |
dispatch_group_leave(contactsGroup) //Leave group | |
}) | |
dispatch_group_enter(contactsGroup) //Enter group again | |
loadContactsAddressBookWithCompletion({ (contacts:[User]) -> () in | |
doStuffWithContacts(contacts) | |
dispatch_group_leave(contactsGroup) //Leave group | |
}) | |
//GCD stores this block to be called once the group "contactsGroup" has no more entrants | |
dispatch_group_notify(contactsGroup, dispatch_get_main_queue(), { [weak self] () -> Void in | |
sortContacts() | |
tableView.reloadData() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment