DispatchGroup example swift
class DispatchGroupExample: UIViewController {
private let dispatchGroup = DispatchGroup()
override func viewDidLoad() {
super.viewDidLoad()
fetchData(url: xxx)
fetchData(url: yyy)
// 3: notify job done
dispatchGroup.notify(queue: .main) {
self.goToNext()
}
}
private func fetchData(url: URL) {
// 1: enter group
dispatchGroup.enter()
URLSession.shared.dataTask(with: url) {
[weak self] (data, urlResponse, error) in
// parse data
...
// 2: leave group
self?.dispatchGroup.leave()
}
}
}vc.setViewControllers([standingsViewController], animated: true)
Also in Swift:
- swift retrieve value from dictionary
- Sending array of dictionaries with alamofire
- swift go to root view controller
- how do i have countdown timer in swift stackoverflow
- swift corner radious of view controller
- Decimal to Double conversion in Swift
- swift clear user defaults
- get item filter count swift
- swift comments
- swift function in a variable
- swift check dictionary has key
- textchange in textview swift
- swift create uinavigationcontroller programmatically
- swift thread.sleep
- remove back button text nav bar swift
- swift change navigation bar title
- how to style textfield swiftui
- init with bindings swiftui
- swift enum
- sqlite in swift
- how to get the path of selected PDF/doc from file manager in ios swift programmatically
- how to get appdelegate object in swift
- how to get key for dictionary in swift
- cross origin requests are only supported for http wkwebview