开发者

Anyone noticed images fail to load after network interruption?

开发者 https://www.devze.com 2022-12-23 18:31 出处:网络
I just noticed that when you get a network interruption the code proposed by Apple fails to load the images ... It works p开发者_如何学JAVAerfectly otherwise though ;)

I just noticed that when you get a network interruption the code proposed by Apple fails to load the images ... It works p开发者_如何学JAVAerfectly otherwise though ;)

It is due to the fact that IconDownloader doesn't do anything if NSURL connection fails ...

Before I struggle with this on my own, anyone has any tips for me :D ?

Thanks a lot,

Gotye.


==> i think this is what we can do to download if nsurlconnection method get fail with connection

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

{
          // Clear the activeDownload property to allow later attempts
            self.activeDownload = nil;

          // Release the connection now that it's finished
       self.imageConnection = nil;


  //i think we can call the connection method again from here

       self.activeDownload = [NSMutableData data];
          // alloc+init and start an NSURLConnection; release on completion/failure
       NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:
                         [NSURLRequest requestWithURL:
                          [NSURL URLWithString:appRecord.imageURLString]] delegate:self];
       self.imageConnection = conn;
       [conn release];



}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号