Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to know when NSURLRequest finish loading

Im implementing an app that shows some Twitter data, when is working on wifi is ok, but on 3g crashes, I have come to the conclusion that is because the NSURLRequest that fetchs the data that populates the table takes longer to load so the table ends up calling an object for key, when the keys havent even loaded,

So the question is, - how can I know when the NSURLRequest finished loading? [I checked the Class Reference but didnt see it??]

Thanks a lot!

like image 751
manuelBetancurt Avatar asked Feb 17 '26 01:02

manuelBetancurt


1 Answers

The delegate methods are invoked on the request's corresponding NSURLConnection, e.g.

    urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];

You will then receive various callbacks included the finished callback as follows:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection{}

Other delegate callbacks are:

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ 

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { 

- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection *)connection{

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
like image 172
Max MacLeod Avatar answered Feb 19 '26 18:02

Max MacLeod



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!