Large File Downloads
This episode covers the complex topic of implementing file downloads with a custom UI. Covers tracking progress, background download support, resuming, and implementing a custom button to show the status of a download.
Length: about 2 hours.
Downloading large files on iOS represents some unique challenges. Downloads should occur in the background, not confined to a particular view controller. They should be able to report progress on multiple screens, and should be robust enough to survive application suspension and failing network conditions, and respect the user's cellular data plan. In this episode we start a series on downloading large files that will cover all of the above concerns.
In this episode we create a DownloadInfo model in CoreData in order to track the state of a download, separate from any view controller.
In this episode we take the download state and progress notifications and update the user interface to reflect this state. We'll see how to translate the notification into the indexPath for that episode row, and how to fake a change related to the fetched results controller to trigger a reload of the content. We will leverage the RateLimit library to save periodic changes in progress to the model without overwhelming Core Data.
In this episode we create a custom control to serve as our download button. We start by creating a circular progress indicator using CAShapeLayer, then move on to subclassing UIControl to provide our image view and touch handling.
Wrapping up our custom download button, this time we focus on the highlighted image and depressed state of the button, as well as transitioning to and from the progress layer.