| Start |
|---|
| Obtaining a Grand Central Dispatch (GCD) queue Grand Central Dispatch works on the concept of "Dispatch Queues". A dispatch queue executes tasks you designate in the order which they are passed. There are three types of dispatch queues:
To access the main queue: The system provides concurrent global dispatch queues (global to your application), with varying priorities. You can access these queues using the equivalent to In iOS 8 or later, the possible quality of service values which may be passed are You can also create your own queues with varying priorities: In Swift 3, queues created with this initializer are serial by default, and passing |
| Concurrent Loops GCD provides mechanism for performing a loop, whereby the loops happen concurrently with respect to each other. This is very useful when performing a series of computationally expensive calculations. Consider this loop: You can perform those calculations concurrently using The loop closure will be invoked for each A couple of special considerations: |
| Running tasks in a Grand Central Dispatch (GCD) queue To run tasks on a dispatch queue, use the To dispatch a task to a queue asynchronously: To dispatch a task to a queue synchronously: To dispatch a task to a queue after a certain number of seconds: NOTE: Any updates of the user-interface should be called on the main thread! Make sure, that you put the code for UI updates inside Types of queue: To dispatch a task to a queue asynchronously: To dispatch a task to a queue synchronously: To dispatch a task to after a time interval (use To execute a task asynchronously and than update the UI: NOTE: Any updates of the user-interface should be called on the main thread! Make sure, that you put the code for UI updates inside |
| Running Tasks in an OperationQueue You can think of an Get the main Create a custom Quality of Service specifies the importance of the work, or how much the user is likely to be counting on immediate results from the task. Add an Add a block to an Add multiple Adjust how many Suspending a queue will prevent it from starting the execution of any existing, unstarted operations or of any new operations added to the queue. The way to resume this queue is to set the Suspending an |
| Creating High-Level Operations The Foundation framework provides the
Create a simple non-concurrent Add an operation to an This will execute the operation concurrently on the queue. Manage dependencies on an Dependencies define other Run an Dependencies will be ignored. If this is a concurrent operation, the task may still be executed concurrently if its Concurrent Operations. If the task that an When implementing an asynchronous Cancel an Calling Syntax |
Read Article
https://develop.horje.com/learn/1434/reference