I have a second NSURLSession that is being called directly from the completionHandler of the previous one (it is dependent on the cookies generated from the first call). It worked for a while and sometimes still works, but most of the time does not. When I set through the debugger, it simply goes from the dataTaskWithRequest line to the line past the task.resume() call. Any thoughts?
func getDates () -> [NSDate] {
var urlDays = NSURL(string: "https://mycorrecturl.com")
var requestDays = NSMutableURLRequest(URL: urlDays!)
let sessionDays = NSURLSession.sharedSession()
// Create array of NSDate objects
var allDates = [NSDate]()
var task = sessionDays.dataTaskWithRequest(requestDays, completionHandler: {data, response, error -> Void in
// Convert into array of NSDate objects
})
task.resume()
return allDates
}
Why would this this dataTaskWithRequest function just not fire?