title: return string inside block of NSURLConnection - Incompatible block pointer types sending
body: <p>I am trying to isolate logic responsible for authentication and retriving the TOKEN inside the function. I have the problem with returning the string with token from BLOCK of NSURLConnetcion.</p>
  
  <p>It causues <code>semantic error</code>: Incompatible block pointer types sending </p>
  
  <pre><code>'NSString *(^)(NSURLResponse *__strong, NSData *__strong, NSError *__strong)' 
  </code></pre>
  
  <p>to parameter of type </p>
  
  <pre><code>'void (^)(NSURLResponse *__strong, NSData *__strong, NSError *__strong)'
  </code></pre>
  
  <p>I am completly newbie to Objective-C, so please be forgiving. Below is my function.</p>
  
  <pre><code>- (NSString*)getToken: (NSString *)username andPassword: (NSString *) password {
  
  NSMutableURLRequest *request1 = [NSMutableURLRequest requestWithURL:
  [NSURL URLWithString:@"http://127.0.0.1:8000/auth_ex"]
  cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:20];
  
  __block NSString * tokens;
  [request1 setHTTPMethod:@"POST"];
  
  NSString * body1 = [NSString stringWithFormat:@"email=%@&amp;password=%@",username,password];
  
  [request1 setHTTPBody: [body1 dataUsingEncoding:NSUTF8StringEncoding]];
  
  NSOperationQueue * queue1 = [[NSOperationQueue alloc]init];
  
  [NSURLConnection
   sendAsynchronousRequest:request1 queue:queue1 completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
       if ([data length] &gt;0 &amp;&amp; connectionError == nil){
           NSDictionary* token = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
           tokens = [token objectForKeyedSubscript:@"token"];
           return tokens;
       }
       else{
           return @"NOT AUTHORIZEd";
       }
   }];
  
  
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/BR145.png" alt="enter image description here"></p>