PDA

View Full Version : Downloading large amount of images, making it faster...




kviksilver
Aug 6, 2010, 12:59 PM
I need help with downloading from webserver...
What i currently do is get XML file from web servers that contains image locations, parse XML, download each image, store image on iphone, and store image name to sql database.
This takes lots of time because there is large amount of images to be downloaded and i am downloading one by one.

My app update just got rejected because reviewer decieded that downloading is too long... What is funny, last two updates passed without problems..

I was thinking about zipping those images on server and sending zip file to iphone, unzipping it there, or packing images together with binary and sending it to apple.

Any advice on how to make download faster, would be appreciated. Thanks.



robbieduncan
Aug 6, 2010, 01:40 PM
Are you downloading on the main thread so the entire UI freezes until the download completes? As that would be a problem. If you are doing that download using the async methods and you should be OK.

PhoneyDeveloper
Aug 6, 2010, 02:03 PM
Obviously you need to give more details.

I believe that NSURLConnection will use compression transparently if the server does this and provides the correct headers. Look up gzip compression on web servers.

You can run multiple NSURLConnections concurrently. You'll need to figure out how many at a time is a good number. Certainly ten at a time would be fine.

You might want to look at Apple's LazyTableImages sample code. It does something like this.

No matter what downloading a few megabytes of images will take some time. The trick is for this to not interfere with the user's ability to use the app.

chown33
Aug 6, 2010, 02:25 PM
The trick is for this to not interfere with the user's ability to use the app.

The other trick is to not make it essential to the first use of the app. Doing so is just bad design.

An app should always include all its essential parts. If there is genuine optional or dynamic content that can't possibly be included in the app, then there may be a case for an initial in-app download. The user experience would have to be carefully managed, because I can't think of any reason why anyone would want to sit through a half-app's half-assed startup.

kviksilver
Aug 7, 2010, 01:43 AM
i can try running multiple nsurlconnections at once...
there isa problem with letting user use application while downloading because app itself is useless without data that is going to be downloaded... :-(

anyway ill post time comparision with nsurlconnection concurently an one by one...


Obviously you need to give more details.

I believe that NSURLConnection will use compression transparently if the server does this and provides the correct headers. Look up gzip compression on web servers.

You can run multiple NSURLConnections concurrently. You'll need to figure out how many at a time is a good number. Certainly ten at a time would be fine.

You might want to look at Apple's LazyTableImages sample code. It does something like this.

No matter what downloading a few megabytes of images will take some time. The trick is for this to not interfere with the user's ability to use the app.