NSProgress
Because the current progress is thread-specific, it is important that the worker object creates its progress object on the same thread it was invoked on. Otherwise, the parent-child relationship will not be set up correctly. Once created,
NSProgress
objects are thread-safe. The worker object can later update properties on the progress from any thread/queue.
The view controller observes the progress using KVO, but the observer method is called on the worker’s thread/queue, so it has to tell the main thread to update the user interface. It seems like this could perhaps be simpler, but overall it looks like NSProgress
has a pretty clean API. It’s definitely one of the more interesting new Cocoa features.