title: NSURLConnection - Grabbing response data when using another class as a delegate, and when there is an authentication challenge
body: <p>I am using my internal api to retrieve data from my server. I am using Basic Authentication to achieve this. Because of the nature of APIs i am not implementing any session or anything else on my server code, so i am sending username and passwords with all of my requests.</p>
  
  <p>Because of this, i don't want to implement NSURLConnection delegates for every viewcontroller i am using. So that, I created a helper class, which extends NSObject, and I set it as a NSURLConnectionDelegate.</p>
  
  <pre><code>@interface HandlerClass : NSObject &lt;NSURLConnectionDelegate&gt;
  </code></pre>
  
  <p>I implemented every method i need, and i am calling it like:</p>
  
  <pre><code>NSURL *URL = [NSURL URLWithString:@"https://url/ifuser/"];
  NSLog(@"Connection ");
  
  NSURLRequest *request = [NSURLRequest requestWithURL:URL
                                           cachePolicy:NSURLRequestReloadIgnoringCacheData
                                       timeoutInterval:30.0];
  
  NSHTTPURLResponse *response;
  
  HandlerClass *cc = [[HandlerClass alloc] init];
  
  cc.username = self.username.text;
  cc.password = self.password.text;
  
  NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:cc];
  </code></pre>
  
  <p>But whatever i try, i cannot reach data response data from that delegate.</p>
  
  <p>I literally tried to read every piece of writing in internet, both including stackoverflow and other sites. Every solution of this requires no authentication.</p>
  
  <p>But i only need the solution with authentication.</p>
  
  <p>Thanks.</p>
  
  <p>~~~~~~~~~~~~~~~~~~~~~~~~~</p>
  
  <p>EDIT: I know i did several redundant errors. But i could be able to figure out what did wrong.
  I just needed to use NSRunLoop to achieve my goal. Thanks all.</p>