Hello,
My app has a stream on Ethernet, which receives informations. These informations (when available) are inserted inside a Dictionary, which is sent to a viewController through a "postNotification" call, one dictionnary after the other (Multiple call to this postNotification to complete import function).
Observer declaration line is:
NotificationCenter.default.addObserver(self, selector: #selector(OtherFunctionsViewController.dataImportExportFunc), name: .ImportExportdata, object: nil)
Inside dataImportExportFunc, as soon as Dictionary is received, a calculus is done to get the value of self.ProgressLevel (float value)
Then, to update UI (managed by the controller), in the function associated to observed message notification, it is done as below:
DispatchQueue.global(qos: .userInteractive).sync { [unowned self] in
DispatchQueue.main.async {
// update some UI
self.OtherFuncProgressView.setProgress(Float(self.ProgressLevel), animated: true)
self.OtherFuncProgressView.setNeedsDisplay()
// print ("dataImportExportFunc (DispatchQueue): Number of requests = \(self.NumberOfRequest), ProgressLevel = \(self.ProgressLevel)")
}
}
The viewController class receives these informations (in dataImportExportFunc function) and calculate progress of import process correctly (progress printed in log message). But in UI, progress of OtherFuncProgressView (which is a UIProgressView) is only updated at the end of import process, and not during this import process. How can I make this UIProgressView updated in real time ? I suppose this is something to do with DispatchQueue which is serial (by default), but I have tried several issues which lead to same results. Thanks for your help in advance
Guy
Configuration:
Xcode Version 10.1 (10B61) on Mac OsX High Sierra v10.13.6 (17G4015). Iphone 6 64 Go v11.4.1(15G77) or simulator iPhone 6 v12.1