0

First of all there a lot of similar questions but they are all about creating of NSURLSessionDataTask with completion handler. In my case I have NSURLConnection with a lot of delegate methods and I need to replace it with NSURLSession.

According to this link I need delegate method URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler: but I can't understand how to use it because all the examples are about creating a task with a completion handler (just success or failure) with no delegate usage at all.

Vyachaslav Gerchicov
  • 2,317
  • 3
  • 23
  • 49
  • Did you tried by setting the delegate of a `NSURLSession` object, and implementing that delegate method if it's called? I may guess that the delegate method will be called before the completion handlers (success/error) of the `NSURLSession` object. – Larme Apr 18 '16 at 08:38
  • I mean I don't how to set `NSURLSession` method. I can't just write `[NSURLSession sharedSession].delegate = self`. Finally the method I mentioned requires `NSURLSessionTaskDelegate`, not `NSURLSessionDelegate` from `NSURLSession`. – Vyachaslav Gerchicov Apr 18 '16 at 08:48
  • You can use `sessionWithConfiguration: delegate: delegateQueue:`. As the doc said with `[NSURLSession sharedSession]`: "As a result, you don’t provide a delegate or a configuration object.". – Larme Apr 18 '16 at 08:51

0 Answers0