I have this code:
MainViewControler:
and Config.swift:
StartUpdatingSplash - runs the splash.
Function downloadImages - runs the thread for downloading photos from the internet. The application after launch displays splash (EZLoadingActivity) and then downloads the photos.
I would like to hide EZLoadingActivity (EZLoadingActivity.hide) after finishing all these threads used to download photos, for example by running the FinishUpdatingSplash () function. How can I do this?
My notificationcenter correctly displays the splash - I have a problem just hide it
MainViewControler:
Code:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
// register notification
NotificationCenter.default.addObserver(self, selector: #selector(MainViewControler.StartUpdatingSplash), name: NSNotification.Name("updating.salestool.bla.pl"), object: nil)
}
@objc func StartUpdatingSplash() {
DispatchQueue.global().async {
EZLoadingActivity.show("LoadingMessage4".localized(), disableUI: true)
}
print("##### NOTIFICATION STEP: 1")
}
@objc func FinishUpdatingSplash() {
DispatchQueue.global().async {
EZLoadingActivity.hide()
}
NotificationCenter.default.removeObserver(self, name: Notification.Name("updating.salestool.bla.pl"), object: nil)
print("##### NOTIFICATION STEP: 2")
}
and Config.swift:
Code:
NotificationCenter.default.post(name: NSNotification.Name("updating.salestool.bla.pl"), object: nil)
let dispatchImagesGroup = DispatchGroup()
dispatchImagesGroup.enter()
DispatchQueue.global().async {
self.downloadImages(toDownloads: jsonData, savedURL: FileFolders.GET_PHOTO.rawValue, parametr: FileFolders.GET_PHOTO.rawValue)
dispatchImagesGroup.leave()
}
dispatchImagesGroup.enter()
DispatchQueue.global().async {
self.downloadImages(toDownloads: jsonData, savedURL: FileFolders.GET_INSPIRATION_PHOTO.rawValue , parametr: FileFolders.GET_INSPIRATION_PHOTO.rawValue)
dispatchImagesGroup.leave()
}
dispatchImagesGroup.enter()
DispatchQueue.global().async {
self.downloadImages(toDownloads: jsonData, savedURL: FileFolders.GET_PACKSHOT.rawValue , parametr: FileFolders.GET_PACKSHOT.rawValue)
dispatchImagesGroup.leave()
}
dispatchImagesGroup.enter()
DispatchQueue.global().async {
self.downloadImages(toDownloads: jsonData, savedURL: (AppGlobalManager.sharedManager.loggedUser?.selectedLanguage)! + "/" + FileFolders.GET_TIPS_SLIDES.rawValue, parametr: FileFolders.GET_TIPS_SLIDES.rawValue)
dispatchImagesGroup.leave()
}
dispatchImagesGroup.enter()
DispatchQueue.global().async {
self.downloadImages(toDownloads: jsonData, savedURL: (AppGlobalManager.sharedManager.loggedUser?.selectedLanguage)! + "/" + FileFolders.GET_LEAFLETS_SLIDES.rawValue, parametr: FileFolders.GET_LEAFLETS_SLIDES.rawValue)
dispatchImagesGroup.leave()
}
dispatchImagesGroup.enter()
DispatchQueue.global().async {
self.downloadImages(toDownloads: jsonData, savedURL: (AppGlobalManager.sharedManager.loggedUser?.selectedLanguage)! + "/" + FileFolders.GET_CONCEPTS_SLIDES.rawValue, parametr: FileFolders.GET_CONCEPTS_SLIDES.rawValue)
dispatchImagesGroup.leave()
}
dispatchImagesGroup.enter()
DispatchQueue.global().async {
self.downloadLeafletsPDF(toDownloads: jsonData, savedURL: (AppGlobalManager.sharedManager.loggedUser?.selectedLanguage)! + "/" + FileFolders.GET_LEAFLETS_PDF.rawValue)
dispatchImagesGroup.leave()
}
dispatchImagesGroup.notify(queue: .global()) {
NotificationCenter.default.addObserver(self, selector: #selector(MainViewControler.FinishUpdatingSplash), name: NSNotification.Name("updating.salestool.bla.pl"), object: nil)
}
StartUpdatingSplash - runs the splash.
Function downloadImages - runs the thread for downloading photos from the internet. The application after launch displays splash (EZLoadingActivity) and then downloads the photos.
I would like to hide EZLoadingActivity (EZLoadingActivity.hide) after finishing all these threads used to download photos, for example by running the FinishUpdatingSplash () function. How can I do this?
My notificationcenter correctly displays the splash - I have a problem just hide it
Last edited: