Created
April 9, 2024 04:39
-
-
Save SysCall97/1135c1948ce824107f5769df0427a710 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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