I tried a couple of things using a separate thread but still no luck. Below is my latest try? I must be missing something basic with this in seems to be very straightforward?
@IBAction func progressStart(_ sender: Any) {
// Start the progress animation
progressIndicator.startAnimation(self)
// Do some work here...
let dispatchGroup = DispatchGroup()
dispatchGroup.enter()
DispatchQueue.global(qos: .background).async {
var progress: Double = 0.0
for _ in 0..<100 {
// Update the progress value in a loop
progress += 1.0
DispatchQueue.main.async {
self.progressLabel.stringValue = String(progress)
self.progressIndicator.doubleValue = progress / 100.0
}
// Do some work here...
}
dispatchGroup.leave()
}
dispatchGroup.notify(queue: DispatchQueue.main) {
// Stop the progress animation
self.progressIndicator.stopAnimation(self)
}
}
}
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: