title: In Objective-C, return something that has to wait before its done
body: <p>Consider following code involving <code>SpecialRequest</code>, which has member <code>result</code> that is not populated right away:</p>
  
  <pre><code>- (NSArray *)getXboxSizedArray {
     SpecialRequest *request = [SpecialRequest request];
     request.someParam = 11; //and so forth...
     [request start];
  }
  </code></pre>
  
  <p>And say there is a callback for <code>requestFinished</code>:</p>
  
  <pre><code>- (void)requestFinished:(SpecialRequest *)request {
     //hooray!
  }
  </code></pre>
  
  <p>I want to return the value of <code>request.result</code>, but of course only after the request has completed (which I would know from <code>-(void)requestFinished</code>. How do I do this?</p>
  
  <p>Edit: Note that I have tried putting a return statement inside a block, and failed miserably.</p>
  
  <p>Edit 1: Here is an example of bad and non working code if you are interested:</p>
  
  <pre><code>- (NSString *)getAllDogFoodBrand {
      __unsafe_unretained __block ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"some_url"]];
      request.delegate = self;
      [request setCompletionBlock:^{
          [self.delegate objectControllerDidFinishRequestWithStatus:request.responseStatusMessage];
          //return request.responseString; &lt;-- this line makes compiler :(
      }];
      [request startAsynchronous];
  }
  </code></pre>