Progress Indicator not working as expected

I have a test project with a bar progress indicator create on Ventura with Xcode 14.3.1., It does not show the any animation until the @IBAction function completes.

I want to show progress as it progresses not a just the end? Any ideas how to fix this? Below is my test project code..

//
//  ViewController.swift
//  ProgressTest
//
//  Created by Bob on 6/5/23.
//

import Cocoa

class ViewController: NSViewController {
    
    @IBOutlet weak var progressIndicator: NSProgressIndicator!
 //   var progress: Double = 0.0
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Do any additional setup after loading the view.
    }
    
    override var representedObject: Any? {
        didSet {
            // Update the view, if already loaded.
        }
    }
    
    @IBAction func progressStart(_ sender: Any) {
        // Start the progress animation
        progressIndicator.startAnimation(self)
        
        // Do some work here...
        // Do some work here...
           var progress: Double = 0.0
           for _ in 0..<100 {
               // Update the progress value in a loop
               progress += 1.0
               progressIndicator.doubleValue = progress

   //         progress = Double(i)
   //         progressIndicator.increment(by: 10)
    //     progressIndicator.doubleValue = progress
            // Do some work here...
        }
        // Stop the progress animation
        progressIndicator.stopAnimation(self)
    }
}
thanks

Bob

Where are you calling progressStart?

This works for me:

class ViewController: NSViewController {
    
    @IBOutlet weak var progressIndicator: NSProgressIndicator!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        progressIndicator.doubleValue = 0
        DispatchQueue.main.async {
            self.progressStart(self.progressIndicator!)
        }
    }
 
    @IBAction func progressStart(_ sender: Any) {
        for progress in 0..<100 {
            // Update the progress value in a loop
            progressIndicator.doubleValue = Double(progress)
        }
    }
}

(No need for startAnimation or stopAnimation, with a determinate progress indicator.)

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)
        }
    }
}

I ended up going a different route, I got it working like I wanted via SwifUI, I wanted to learn more about SwiftUI so this is a better way to go.

Progress Indicator not working as expected
 
 
Q