title: Recursion with blocks in objective-c
body: <p>I am receiving EXC_BAD_ACCESS signal in my iOS application when doing a recursion that involves objective-c blocks. Here is the simplified code:</p>
  
  <pre><code>- (void)problematicMethod:(FriendInfo*)friendInfo onComplete:(void(^)(NSString*))onComplete1 {
  
  [self doSomethingWithFriend:friendInfo onComplete:^(Response* response) {
      switch (response.status) {
          case IS_OK:
              onComplete1(message);
              break;
  
          case ISNT_OK:
              // Recursively calls the method until a different response is received 
              [self problematicMethod:friendInfo onComplete:onComplete1];
              break;          
  
          default:
              break;
      }
  }];
  }
  </code></pre>
  
  <p>So basically, the <em>problematicMethod</em>, in this simplified version, calls <em>doSomethingWithFriend:onComplete:</em>. When that method finishes (<em>onComplete</em>), and if everything was ok, the original <em>onComplete1</em> block gets called, and this works fine.</p>
  
  <p>But if something went wrong, <em>problematicMethod</em> needs to be called again (the recursion part), and when this happens for the first time, I immediately get EXC_BAD_ACCESS signal.</p>
  
  <p>Any kind of help would be greatly appreciated.</p>