I would like to process data as it comes in, so I\'ve instiated a URL session like so:
let session = URLSession(configuration: sessionConfiguration, delegate
The reason this is not working is that you're creating your data task with a completion handler. Instead you must use the dataTask(with:)
function instead.
I also missed this in the documentation and spent hours wondering why my delegate methods weren't being called.
From the docs:
By using the completion handler, the task bypasses calls to delegate methods for response and data delivery, and instead provides any resulting NSData, URLResponse, and NSError objects inside the completion handler. Delegate methods for handling authentication challenges, however, are still called.