2

I have an iOS application, where I need to download over 60-70 videos a week of size 3-8MB each. The issue is, how do I download these videos? I am storing the list of videos and urls in a database.

Possible solutions:

Use a UIBackgroundTaskIdentifier, call beginBackgroundTaskWithExpirationHandler as soon as the app starts. This task will download one video.
In the endBackgroundTask I will mark that particular video as downloaded.
Concerns here are, can I start multiple UIBackgroundTaskIdentifier? Where should I start them? In AppDelegate? A particular controller? If I start it in a particular controller, on viewDidLoad() what will happen if the app exits?

Please guide me or provide an alternate solution. Thanks

Emil
  • 7,220
  • 17
  • 76
  • 135
manishKungwani
  • 925
  • 1
  • 12
  • 44

2 Answers2

5

Use AFNetworking as ASIHTTPRequest is deprecated.

Refer AFNetworking source link.

Also refer afnetworking-downloading-multiple-files link and Does AFNetworking have backgrounding support link.

EDIT : start downloading in AppDelegate

Check AFDownloadRequestOperation for resumable download.

Refer afnetworking-pause-resume-downloading-big-files using AFDownloadRequestOperation link.

Community
  • 1
  • 1
Paresh Navadiya
  • 38,095
  • 11
  • 81
  • 132
  • Thanks for the reply, I also want to know, where do you call this function? In the AppDelegate or in a particular controller? Also, what happens if the app is quit before the download finishes? Thanks – manishKungwani Nov 19 '12 at 10:40
  • Awesome, Im almost there, one last question? I have to download multiple files, so what I will do is have a for loop and start the download for every file one after the other, using one of the above solutions, anything wrong with that or any alternate solution to it? Thanks again – manishKungwani Nov 19 '12 at 11:26
2

You can download multiple files with ASIHTTPRequest in the background. See the documentation here.

Please note that ASIHTTPRequest is no longer working so you can use AFNetworking.

AFNetworking is a delightful networking library for iOS and Mac OS . It's built on top ofNSURLConnection,NSOperation, and other familiarFoundation technologies`. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use.

Find the SDK here.

Emil
  • 7,220
  • 17
  • 76
  • 135
Siba Prasad Hota
  • 4,779
  • 1
  • 20
  • 40