ASIHttpRequest
ios - Limit NSURLConnection data rate? (Bandwidth throttling) - Stack Overflow

seen from United States
seen from China
seen from China

seen from United States

seen from United States
seen from China

seen from United States
seen from United States
seen from United States
seen from Peru
seen from United States
seen from Türkiye

seen from United States
seen from Bangladesh
seen from Bulgaria
seen from Germany
seen from United States
seen from Finland
seen from Peru
seen from China
ASIHttpRequest
ios - Limit NSURLConnection data rate? (Bandwidth throttling) - Stack Overflow
Interesting NSURLConnection quirk
You would expect this code always return a response, sometimes return data, and when there was no data, you could look at the response and the error to determine what happened. Not so! The response object is `nil` if it hits a NSURLErrorUserCancelledAuthentication (-1012). NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; if (!data) NSLog(@"Network error: HTTP %i - %@", [response statusCode], error); Changed to the code below, for now. Not sure how to deal with it long term though, may have to move away from my `sendSynchronousRequest` from within an `NSBlockOperation` technique of network queuing. NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; if (!data || !response) NSLog(@"Network error: HTTP %i - %@", [response statusCode], error);
Using NSRunLoop and NSURLConnection
This article illustrates the use of NSURLConnection with NSRunLoop. [More...](http://coc24hours.blogspot.com/2012/01/using-nsrunloop-and-nsurlconnection.html)
How to make monitor progress for an NSURLConnection when downloading a file
In your **NSURLConnection** delegate, implement something like the following to find out the total content length. The server has to support this, but it will most likely work fine with static content: - (void)connection: (NSURLConnection*) connection didReceiveResponse: (NSHTTPURLResponse*) response { if ([response statusCode] == 200) { self.downloadSize = [response expectedContentLength]; } } You can update progress like so: - (void) connection: (NSURLConnection*) connection didReceiveData: (NSData*) data { [self.data appendData: data]; self.progress = ((float) [self.data length] / (float) self.downloadSize); // Broadcast a notification with the progress change, call a delegate, etc. }
A dirty hack, but it seems to work OK. Use at your own risk... ;)
[The behavior of NSURLCache changed between iOS 4.x and iOS 5.x](http://petersteinberger.com/blog/2012/nsurlcache-uses-a-disk-cache-as-of-ios5/)
NSURLConnectionDownloadDelegate doesn't work
Surprise undocumented fact: NSURLConnectionDownloadDelegate is only for Newsstand apps. If you attempt to use it in a non-Newsstand app, it will appear to succeed but pass you a nonexistent file path.
More generally, Newsstand is pretty neat but it's silly for Apple to restrict its functionality to news apps. For example, take my subway app: it could definitely benefit from downloading service change data daily if you're plugged in at 4AM (which is what Newsstand allows you to do). But since I'm not a "news" app, I can't do that.