In an app I’m currently working on, I use NSURLSession download tasks to retrieve data from the network. I use the delegate methods so I can get notified of progress and fill in the details of an NSProgress object.
The first thing to note is that while the following method appears to be about errors, it actually gets called on the completion of a task. If the task is successful, the error is nil. This actually went unnoticed far too long, leading to duplicate parsing of the data.
Another issue I’ve come across recently is that, due to the former bug, I wanted a single place to handle completion of the task. So, I ended up storing the location of the downloaded data from the following delegate method call and using it in the above method to retrieve the data.