title: NSURLSession delegate vs. completionHandler
body: <p>I've always used completion handlers. With <code>NSURLConnection</code> and now with <code>NSURLSession</code>. It's led to my code being really untidy, especially I have request within request within request.</p>
  
  <p>I wanted to try using delegates in <code>NSURLSession</code> to implement something I've done untidily with <code>NSURLConnection</code>. </p>
  
  <p>So I created a <code>NSURLSession</code>, and created a <code>dataTask</code>: </p>
  
  <pre><code>NSURLSessionDataTask *dataTask = [overallSession dataTaskWithURL:url
                                                    completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                        if(error == nil)
                                                        {
                                                            NSString * text = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
                                                            NSLog(@"Data = %@",text);
                                                        }
  
                                                    }];
  
      [dataTask resume];
  </code></pre>
  
  <p>Right now I have a <code>completionHandler</code> for the response, how would I switch to delegates to manage the response and data? And can I add another <code>dataTask</code> from the delegate of this one? Using the cookies that this <code>dataTask</code> created and placed into the session?</p>