title: How do you schedule a block to run on the next run loop iteration?
body: <p>I want to be able to execute a <code>block</code> on the next run loop iteration. It's not so important whether it gets executed at the beginning or the end of the next run loop, just that execution is deferred until all code in the current run loop has finished executing.</p>
  
  <p>I know the following doesn't work because it gets interleaved with the main run loop so my code might execute on the next run loop but it might not.</p>
  
  <pre><code>dispatch_async(dispatch_get_main_queue(),^{
      //my code
  });
  </code></pre>
  
  <p>The following I believe suffers the same problem as above:</p>
  
  <pre><code>dispatch_after(DISPATCH_TIME_NOW, dispatch_get_main_queue(), ^(void){
      //my code
  });
  </code></pre>
  
  <p>Now I <em>believe</em> the following would work as it is placed at the end of the current run loop (correct me if I'm wrong), would this actually work?</p>
  
  <pre><code>[self performSelector:@selector(myMethod) withObject:nil afterDelay:0];
  </code></pre>
  
  <p>What about a timer with a <code>0</code> interval? The documentation states: <code>If seconds is less than or equal to 0.0, this method chooses the nonnegative value of 0.1 milliseconds instead.</code> Does this translate to guaranteeing execution on the next run loop iteration?</p>
  
  <pre><code>[NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(myMethod) userInfo:nil repeats:NO];
  </code></pre>
  
  <p>That's all the options I can think of but I'm still no closer to executing a block (as opposed to calling a method) on the next run loop iteration with the guarantee that it won't be any sooner.</p>