Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There's no direct support for that in GCD. You can probably get the effect you're looking for in other ways, though. </p> <ul> <li><p>Do you just want to run a block after other blocks have completed? Put the blocks in a <code>dispatch_group</code>, and submit your "after everything's done action" using <code>dispatch_group_notify</code>. This works with concurrent or sequential queues.</p></li> <li><p>Similarly, put your blocks in a group, and call <code>dispatch_group_wait(group, DISPATCH_TIME_NOW)</code>. If it returns non-zero, then there are outstanding blocks in the group.</p></li> <li><p>Is your queue sequential, and you want to wait until the other blocks have completed, blocking the current thread until then? Just issue your handler using <code>dispatch_sync</code> on the same queue.</p></li> </ul> <p>There are other possibilities, depending on your exact situation.</p> <p><strong>Edit:</strong> Based on your update, there's an even easier way:</p> <ul> <li>add a <code>BOOL</code> property to your view controller, called <code>allowsOrientationChange</code></li> <li>override <code>-shouldAutorotateToInterfaceOrientation:</code> to return <code>self.allowsOrientationChange</code></li> <li>at the start of your work block, do a <code>dispatch_async</code> to set the property to NO</li> <li>at the end of your work block, do a <code>dispatch_async</code> to set the property to YES</li> </ul> <p>(There's a little bit of a race condition between when the property is set to NO on the main thread, and when the rest of your work happens in the queue. You could make it a <code>dispatch_sync</code> if that really matters. Depends on what your reasons are for preventing rotation, I suppose.)</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. 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