Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The various links in the comments don't say "it's better not to do it." They say you can't do it. You must either pass the queue you want or dispatch to a known queue. Dispatch queues don't have the concept of "current." Blocks often feed from one queue to another (called "targeting"). By the time you're actually running, the "current" queue is not really meaningful, and relying on it can (and historically did) lead to dead-lock. <code>dispatch_get_current_queue()</code> was never meant for dispatching; it was a debugging method. That's why it was removed (since people treated it as if it meant something meaningful).</p> <p>If you need that kind of higher-level book-keeping, use an <code>NSOperationQueue</code> which tracks its original queue (and has a simpler queuing model that makes "original queue" much more meaningful).</p> <p>There are several approaches used in UIKit that are appropriate:</p> <ul> <li>Pass the call-back dispatch_queue as a parameter (this is probably the most common approach in new APIs). See <code>[NSURLConnection setDelegateQueue:]</code> or <code>addObserverForName:object:queue:usingBlock:</code> for examples. Notice that <code>NSURLConnection</code> expects an <code>NSOperationQueue</code>, not a <code>dispatch_queue</code>. Higher-level APIs and all that.</li> <li>Call back on whatever queue you're on and leave it up to the receiver to deal with it. This is how callbacks have traditionally worked.</li> <li>Demand that there be a runloop on the calling thread, and schedule your callbacks on the calling runloop. This is how <code>NSURLConnection</code> historically worked before queues.</li> <li>Always make your callbacks on one of the well-known queues (particularly the main queue) unless told otherwise. I don't know of anywhere that this is done in UIKit, but I've seen it commonly in app code, and is a very easy approach most of the time.</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload