Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>IMHO, neither. </p> <p>The preferred way should be having an <em>object</em> which knowns <em>where</em> to execute its actions:</p> <pre><code>completion_block_t completionHandler = ^(id result) { ... }; AsyncOperation* op = [AsyncOperation alloc] initWithCompletion:completionHandler]; [op start]; // executes its actions on a private execution context </code></pre> <p>Then, one can wrap those AsyncOperation objects into a convenient method:</p> <pre><code>- (void) fetchUsersWithCompletion:(completion_block_t)completionHandler { NSDictionary* params = ...; self.currentOperation = [[HTTPOperation alloc] initWithParams:params completion:completionHandler]; [self.currentOperation start]; } </code></pre> <p>The client may only be interested in specifying <em>where</em> its completionHandler should be executed. The API may be enhanced as follows:</p> <pre><code>- (void) fetchUsersWithQueue:(NSOperationQueue*)handlerQueue withCompletion:(completion_block_t)completionHandler { NSDictionary* params = ...; self.currentOperation = [[HTTPOperation alloc] initWithParams:params completion:^(id result){ // As per the documentation of HTTPOperation, the handler will be executed // on an _unspecified_ execution context. // Ensure to execute the client's handler on the specified operation queue: [handlerQueue:addOperationWithBlock:^{ completionHandler(result); }]; }]; [self.currentOperation start]; } </code></pre> <p>The latter API can be used as this:</p> <pre><code>[self fetchUsersWithQueue:[NSOperation mainQueue] completion:^(id result){ self.users = result; [self.tableView reloadData]; }]; </code></pre>
    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.
    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