Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes — in the first case you create a block and post that off to the main queue. <code>dispatch_async</code> will <code>copy</code> the block. Copying a block causes it to retain every object it references. So <code>self</code> will be retained, as would any other object you mention in the block. The mechanism that keeps hold of the block is Grand Central Dispatch.</p> <p>In the second case you simply schedule a call to <code>doSomething</code> on the main thread. The mechanism that makes the call will be a run loop. <code>self</code> and at most one argument object will be retained.</p> <p>A difference between GCD and run loops is that run loops have modes. You queue things up to be executed only when the run loop is in a compatible mode. In practice you'll most commonly use that by queueing something up to occur in <code>NSDefaultRunLoopMode</code>. When the user is interacting with the user interface it switches into a mode other than the default. Therefore your work will not occur until the user stops interacting. E.g. on iOS the user is considered to be interacting while their finger is down. So you can arrange for work that you know is too heavy to allow, say, smooth scrolling to continue so that it doesn't happen until immediately after the user has finished the interaction.</p> <p>The selector you nominate will use <code>NSRunLoopCommonModes</code> which includes tracking (user interaction) mode but compare and contrast with <code>performSelectorOnMainThread:...modes:</code>.</p>
    singulars
    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. 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.
 

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