I am trying to download a mp3 file at a given link using NSURLConnection. However, I usually get time-out errors. Entering the link into the browser shows the default player, however the music file is not loaded either:

However, if I create the following simple HTML file:
<html>
<body>
<a href="link_to_the_mp3" target="_blank">Download</a>
</body>
</html>
And then load the file into Safari, right click on the Download link, then select Download to Computer (or whathever it’s called in English), Safari downloads the file.
Any ideas on how I can implement this in my own app?
I tried using
NSData *data = [NSData dataWithContentsOfURL:url];
and
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *r, NSData *data, NSError *e) { /.../ }];`
without success.
Seems like you’re trying to hit a fly with a sledgehammer, using “
NSURLConnection“.Try doing something a wee bit more high level such as
NSData * mp3data = [[NSData alloc] initWithContentsOfURL:options:error: ];(the added benefit here is that you can get useful errors back via the “
error:” parameter you pass into the method.