- I cannot find task.resume() in your code. Is it included in the `//....`? Also I needed to fill unmatching `)`.- Xcode claims delegate method signature should be:func URLSession(session: NSURLSession, task: NSURLSessionTask, willPerformHTTPRedirection response: NSHTTPURLResponse, newRequest request: NSURLRequest, completionHandler: (NSURLRequest?) -> Void)The type of `completionHandler` is (NSURLRequest?) -> Void, not (NSURLRequest!) -> Void .- In general, you have no need to handle redirection by yourself. NSURLSession and its tasks will do it appropriately, including cookie handling.- Usual browsers do not send back all header fields included in the redirecting response header. In some cases, sending back all may cause problems.You might need to handle HTTPCookieStorage properly, rather than implementing redirection delegate method.
Topic:
Programming Languages
SubTopic:
Swift
Tags: