0

Here is the point: I've got an app that runs with a set of images in very low resolution. Nothing special here.

When the app starts, I'd like it starts the synch download of full resolution photos set process (photos are downloaded off a remote server). As the file is typically large (>1Gb), I need a way to resume from a potential stop (whatever the reasons), so that it eventually have 100% of photo set on the device without having to start over from the start.

How would you do that?

Stéphane de Luca
  • 12,745
  • 9
  • 57
  • 95
  • 1
    One thing I'd advise (if you haven't already thought about this) is to warn the user that the app will download that much data, and ideally give an option to only download while connected to a wifi connection. I'm sure you don't want to burn through your user's mobile data allowance that fast! – JustAnotherCoder Jun 09 '14 at 12:08
  • I agree with Tom, but if you still want to resume you could try setting up an array of photos and download each photo and copy it to an NSMutableArray and archive it then continue downloading the next photo. Then if your download is interrupted it will resume by making a count of the array and downloading the appropriate photo as indicated by the count. – Scott Jun 09 '14 at 12:32

1 Answers1

0

Your question does not tells about the data in details. There are 2 cases possible :

  1. You are downloading all the images as a single file(like .zip) or in a single request : In this case you can use NSURLSession which has the pause and resume facility inbuilt.
  2. You are downloading the images one by one : In this case you need to have track of the images with some id or index to start the download from a particular file in a sequential manner. For each file pause and resume facility you can use NSURLSession.
Amit
  • 1,043
  • 1
  • 10
  • 32