Networking with URLSession - Part 7: Background | Ray Wenderlich

Download and upload tasks can run in a background session. Find out how the system handles this, and learn some advice and tips for long-running tasks.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3986-networking-with-urlsession/lessons/7

I think maybe there is a error in the finished challenge playground. In the method URLSession:dataTask:didReceiveData: , the data should append.
so my english not very good, i just think so

hi, thanks for your question! it helps to show the difference between the delegates for data task and download task.

A data task usually downloads a small amount of data, which is stored in memory, so didReceiveData receives all of it, then just saves it somewhere in the app.

A download task’s data can be very large, so it’s stored in a file while it downloads. The system calls the delegate method didWriteData in HalfTunes whenever it appends more data to this file.

Incase any newbies get hung up: need to remove fileprivate for trackIndex method on APIManager in order to be accessed from SearchViewController extension.

2 Likes