6

The Situation
In my app, I am currently downloading an mp3 file (to docs directory) using [NSData dataWithContentsOfURL:URL], a method that works fine, but ties down the CPU, dissallowing screen updates of download status. So, I want to download using a different method so that I can update the screen WHILE downloading to alert the user that the download has begun.

Question
How do I set up my viewController to use NSURLRequest or NSURLConnection to download an mp3 file? (please give source)

RexOnRoids
  • 14,002
  • 33
  • 96
  • 136
  • You could just execute `[NSData dataWithContentsOfURL:URL]` on the background thread to avoid UI issues... in fact you should do this with any intensive processes that don't involve the UI. – Sam Spencer May 23 '13 at 23:36

1 Answers1

8

Use "NSURLConnection asynchronously" search for the term and you'll find source. Or just NSURLConnection.

For example:

NSURLConnection NSURLRequest proxy for asynchronous web service calls

Community
  • 1
  • 1
Jordan
  • 21,746
  • 10
  • 51
  • 63