title: iPhone EXC_BAD_ACCESS on accessing instance var in block
body: <p>I've got a question about instance variables in combination with blocks &amp; arc in Objective C with IOS5.</p>
  
  <p>Shortly, when i access this code, the iPhone gives me an EXC_BAD_ACCESS and terminates:
  </p>
  
  <pre><code>- (void) doRequest: (void (^)(XMLTreeNode*) )completionHandler {
      NSString * urlString = [NSString stringWithFormat:@"blablaurl=%@&amp;", action];
  
      for( NSString* key in parameters ){
          urlString = [urlString stringByAppendingFormat:@"&amp;%@=%@", key, [parameters objectForKey:key]];
      }
      NSURL * url = [NSURL URLWithString:urlString];
  
      NSLog( @"Visiting: %@", [url absoluteString] );
  
      NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL:url];
      [request setHTTPMethod:@"GET"];
  
      [NSURLConnection sendAsynchronousRequest:request queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse * response, NSData * data, NSError * err) {
              NSLog( @"Params=%@", parameters );
          completionHandler(e);
      }];
  }
  </code></pre>
  
  <p>The exc_bad_access occurs on:
  NSLog( @"Params=%@", parameters );</p>
  
  <p>(parameters is an instance variable of the class).. Just defined in the header file, no special property or what-so-ever.. </p>
  
  <p>Why does it crash and how can i prevent it? Thanks!</p>
  
  <p>My guess is that it crashes because the objects lifetime is over after the doRequest call, and thus ARC cleans up all variables (and with that the parameter var).. When the urlconnection completes and calls the block, the instance variables are aready cleaned up..</p>