title: NSOperationQueue addOperationWithBlock with return in iOS
body: <p>I have written method <strong>-(void) getStatus:(NSString*) url</strong> with return type,</p>
  
  <pre><code>-(NSString) getStatus:(NSString*) statusUrl
  {
     NSURL *urlObj = [NSURL URLWithString:[statusUrl 
     stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
     NSError *err;
  
     NSString *response = [NSString stringWithContentsOfURL: urlObj encoding: 
     NSUTF8StringEncoding error:&amp;err];
  
     return response;
  }
  </code></pre>
  
  <p>But <strong>stringWithContentsOfURL</strong> is performing operation in main Thread, So while calling this method application struck for a second. </p>
  
  <p>So I need to perform <strong>stringWithContentsOfURL</strong> function in background thread and after getting the response i want to return the response.</p>
  
  <p>My current code:</p>
  
  <pre><code>-(NSString) getStatus:(NSString*) statusUrl
  {
     NSURL *urlObj = [NSURL URLWithString:[statusUrl 
     stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
     NSError *err;
  
     NSOperationQueue *rbQueue = [[[NSOperationQueue alloc] init] autorelease];
     [rbQueue addOperationWithBlock:^{
  
        NSString *response = [NSString stringWithContentsOfURL: urlObj 
        encoding: NSUTF8StringEncoding error:&amp;err];
  
        [[NSOperationQueue mainQueue] addOperationWithBlock:^{
          return response;
        }];
     }];
  
     return @"";
  }
  </code></pre>
  
  <p>But now me receiving a empty string @"", I can not receive response i got from server. Is there any way to do the same task..</p>