3

I've been trying to use the new NSProgress class to report the progress of an operation in my Mac app. Right now, it's saved as a property in my App Delegate (and is updated from a different class and a different queue), and seems to be updated correctly, as proven by logging [_currentProgress fractionCompleted].

However, my issues come when I try to update a progress bar using the NSProgress object. I've got the progress bar set up with bindings something like this:

Binding Screenshot

The progress bar seems to stay on whatever my null placeholder is (as proven by changing the null placeholder to '1'), not redrawing or updating to accommodate any further progress. currentProgress is only set once an operation has started, which will be why the progress bar uses the null placeholder at first, but it makes no effort to update the progress bar when an NSProgress object is set to that property.

It'd be great if somebody could help me out here… (There must be something stupid I'm doing wrong!)

Ben
  • 305
  • 4
  • 13
  • Create a new double property in your app delegate, assign the fractionCompleted to this property and bind your progress bar to this double value. It should update now and you may get a clue how to resolve the progress binding things also – Aneesh Dangayach Apr 07 '14 at 23:20

2 Answers2

1

Unless you say otherwise I am going to assume you are using an indeterminate progress bar.

Cocoa NSProgressIndicator can be indeterminate, in which case it is a barber shop style swirly that is either moving or not:

A picture of an indeterminate progress bar

Or, they can be determinate, in which case it is a typical left to right wipe progress bar:

A picture of a determinate progress bar

Try unchecking indeterminate and seeing if your progress shows up using this settings:

Progress bar settings panel

  • OK, sorry for the delay in response, and thanks for taking the time to answer, but this isn't my issue. My progress bar (which is actually a subclass of NSProgressIndicator, but I get the same behaviour if I use it anyway). It's _not_ set to be an indeterminate progress bar, and I've managed to set it directly in code in the past. However, I've been trying to migrate to updating it using NSProgress and Cocoa Bindings, which is where I start running into problems. – Ben May 01 '14 at 19:51
0

I think the problem is that you cannot use bindings for fractionCompleted if the used NSProgress is being updated on a background queue. I am implementing this combo myself right now and I don't get a bar to appear via normal bindings like you. If I spect to KVO-observing it and setting the bar's doubleValue it works... as long I dispatch that onto the main queue.

Cocoanetics
  • 8,171
  • 2
  • 30
  • 57