Downloading large amount of images, making it faster...

Discussion in 'iOS Programming' started by kviksilver, Aug 6, 2010.

  1. kviksilver macrumors newbie


    Jul 15, 2008
    Makarska, Croatia -> Boston, MA
    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.
  2. robbieduncan Moderator emeritus


    Jul 24, 2002
    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.
  3. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    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.
  4. chown33 macrumors 604

    Aug 9, 2009
    on the Western Slopes, with E. A. Poe
    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.
  5. kviksilver thread starter macrumors newbie


    Jul 15, 2008
    Makarska, Croatia -> Boston, MA
    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...


Share This Page