Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SysCall97/1135c1948ce824107f5769df0427a710 to your computer and use it in GitHub Desktop.
Save SysCall97/1135c1948ce824107f5769df0427a710 to your computer and use it in GitHub Desktop.
import UIKit
class SplashViewController: UIViewController {
var launchDataDispatchGroup: DispatchGroup = DispatchGroup()
override func viewDidLoad() {
super.viewDidLoad()
DispatchQueue.global().async { [weak self] in
self?.getAppLaunchData()
}
}
private func getAppLaunchData() {
launchDataDispatchGroup.enter()
NetworkManager.shared.getData(for: .appConfig) { response in
launchDataDispatchGroup.leave()
// whatever you want to do with the response
}
launchDataDispatchGroup.enter()
NetworkManager.shared.getData(for: .user) { response in
launchDataDispatchGroup.leave()
// whatever you want to do with the response
}
launchDataDispatchGroup.notify(queue: .main) { [weak self] in
// move to the homescreen since all the API responses are received
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment