title: Using blocks within blocks in Objective-C: EXC_BAD_ACCESS
body: <p>Using iOS 5's new <code>TWRequest</code> API, I've ran into a brick wall related with block usage.</p>
  
  <p>What I need to do is upon receiving a successful response to a first request, immediately fire another one. On the completion block of the second request, I then notify success or failure of the multi-step operation.</p>
  
  <p>Here's roughly what I'm doing:</p>
  
  <pre><code>- (void)doRequests
  {
      TWRequest* firstRequest = [self createFirstRequest];
      [firstRequest performRequestWithHandler:^(NSData* responseData,
                                                NSHTTPURLResponse* response,
                                                NSError* error) {
          // Error handling hidden for the sake of brevity...
          TWRequest* secondRequest = [self createSecondRequest];
          [secondRequest performRequestWithHandler:^(NSData* a,
                                                     NSHTTPURLResponse* b,
                                                     NSError* c) {
              // Notify of success or failure - never reaches this far
          }];
      }];
  }
  </code></pre>
  
  <p>I am not retaining either of the requests or keeping a reference to them anywhere; it's just fire-and-forget.</p>
  
  <p>However, when I run the app, it crashes with <code>EXC_BAD_ACCESS</code> on:</p>
  
  <pre><code>[secondRequest performRequestWithHandler:...];
  </code></pre>
  
  <p>It executes the first request just fine, but when I try to launch a second one with a handler, it crashes. What's wrong with that code?</p>
  
  <hr>
  
  <p>The methods to create the requests are as simple as:</p>
  
  <pre><code>- (TWRequest*)createFirstRequest
  {
      NSString* target   = @"https://api.twitter.com/1/statuses/home_timeline.json";
      NSURL* url         = [NSURL URLWithString:target];
      TWRequest* request = [[TWRequest alloc]
                            initWithURL:url parameters:params
                            requestMethod:TWRequestMethodGET];
      // _twitterAccount is the backing ivar for property 'twitterAccount',
      // a strong &amp; nonatomic property of type ACAccount*
      request.account    = _twitterAccount;
  
      return request;
  }
  </code></pre>