title: Getting data out of the NSURLResponse completion block
body: <p>It looks like I didn't get the concept of blocks completely yet...   </p>
  
  <p>In my code I have to get out the JSON data from the <code>asychronous block</code> to be returned to from the '<code>outer</code>' method. I googled and found that if defining a <code>variable with __block</code>, the v̶i̶s̶i̶b̶i̶l̶i̶t̶y̶  <code>_mutability_ of</code> that variable is extended to the <code>block</code>.</p>
  
  <p>But for some reason returned json object is nil.I wonder why?</p>
  
  <pre><code>- (NSMutableDictionary *)executeRequestUrlString:(NSString *)urlString
  {
  __block NSMutableDictionary *json = nil;
  NSURL *url = [NSURL URLWithString:urlString];
  NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
  
  [request setHTTPShouldHandleCookies:YES];
  [request setHTTPMethod:@"GET"];
  [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-type"];
  
  NSString *cookieString = [self.userDefaults objectForKey:SAVED_COOKIE];
  
  [request addValue:cookieString forHTTPHeaderField:@"Cookie"];
  
  [NSURLConnection sendAsynchronousRequest:request
                                     queue:[NSOperationQueue currentQueue]
                         completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
                         {
  
                             NSLog(@"dataAsString %@", [NSString stringWithUTF8String:[data bytes]]);
  
                             NSError *error1;
                             NSMutableDictionary * innerJson = [NSJSONSerialization
                                     JSONObjectWithData:data
                                                options:kNilOptions
                                                  error:&amp;error1];
                             json = innerJson;
  
                         }];
  
      return json;
  }
  </code></pre>