The prototype of blocks submitted to dispatch queues, which take no arguments and have no return value.
- iOS 4.0+
- macOS 10.6+
- tvOS 9.0+
- watchOS 2.0+
The declaration of a block allocates storage on the stack. Therefore, this example demonstrates an invalid construct:
What is happening behind the scenes:
As the example demonstrates, the address of a stack variable is escaping the scope in which it is allocated.
Managing Units of Work
Creates a new dispatch block on the heap using an existing block and the given flags.
Creates a new dispatch block on the heap from an existing block and the given flags, and assigns it the specified QoS class and relative priority.
Creates, synchronously executes, and releases a dispatch block from the specified block and flags.
Waits synchronously until execution of the specified dispatch block has completed or until the specified timeout has elapsed.
Schedules a notification block to be submitted to a queue when the execution of a specified dispatch block has completed.