title: Passing a block as a parameter
body: <p>Is it possible to pass a fully formed block (a block with all its parameters included) into a method to then have that block executed in the method?</p>
  
  <p>At the moment I have this structure repeated in my project:</p>
  
  <pre><code> if (//block exists)
          {
              if (self.returnOnMainThread)
              {
                  dispatch_async(dispatch_get_main_queue(), ^
                                 {
                                     //call block here
                                 });
              }
              else
              {
                  //call block here
              }
          }
  </code></pre>
  
  <p>However ideally I'd like to abstract the above clunk of code out into a method similar to:</p>
  
  <pre><code>- (void) reportSuccessWithBlock:(GenericBlockType)block{
          if (block)
          {
              if (self.returnOnMainThread)
              {
                  dispatch_async(dispatch_get_main_queue(), ^
                                 {
                                     block;
                                 });
              }
              else
              {
                  block;
              }
          }
  
  }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>The block's type wouldn't be known in advance.</p>
  
  <p>So the call path could look like this</p>
  
  <pre><code>- (void) someMethod:(void (^)(NSArray *array))success
  {
  //Some code here setting up the array to be passed back
  
     [self reportSuccessWithBlock:success(array)];
  
  }
  </code></pre>
  
  <p>There are a few assumptions in the above code (that I don't know are possible):</p>
  
  <ol>
  <li>Methods can accept generic block types</li>
  <li>A block can be passed with all its parameters present but without actually executing</li>
  </ol>