Creates and returns an NSProgress instance attached to the specified parent with the totalUnitCount set to portionOfParentTotalUnitCount.


init(totalUnitCount unitCount: Int64, parent: Progress, pendingUnitCount portionOfParentTotalUnitCount: Int64)



The total number of units of work to be carried out.


The parent for the created NSProgress object.


The unit count for the progress object.


Use this method to initialize a progress object with a specified parent and unit count.

In many cases you can simply precede code that does a substantial amount of work with an invocation of this method, then repeatedly set the completedUnitCount or isCancelled property in the loop that does the work.

You can invoke this method on one thread and then message the returned NSProgress on another thread. For example, you can capture the created progress instance in a block that you pass to dispatch_async(_:_:). In that block you can invoke methods like becomeCurrent(withPendingUnitCount:) or resignCurrent(), and set the completedUnitCount or isCancelled properties as work is carried out.

See Also

Creating Progress Objects

init(parent: Progress?, userInfo: [ProgressUserInfoKey : Any]?)

Initializes a newly allocated NSProgress instance.

class func discreteProgress(totalUnitCount: Int64) -> Progress

Creates and returns an NSProgress instance with the specified totalUnitCount that is not part of any existing progress tree. The instance is initialized using init(parent:userInfo:) with the parent set to nil.

init(totalUnitCount: Int64)

Creates and returns an NSProgress instance, initialized using init(parent:userInfo:).