0

I've got question that similiar to this post ASIHTTP asynchrounous pdf download

I am going to resume download using setTemporaryFileDownloadPath: but the weird thing is when I called setDelegate to self and start the connection asynchronously, the cache won't save it to temporaryFileDownloadPath but instead I remark the set delegate, the cache will save to the path.

    _conn = [[ASIHTTPRequest alloc] initWithURL:_currentURL];
    [_conn setDownloadDestinationPath:_currentFileNameWithPath]; 
    [_conn setTemporaryFileDownloadPath:tempPdfLocation];     
    [_conn setAllowResumeForFileDownloads:YES];
    //[_conn setDelegate:self];
    [_conn startAsynchronous];

I've found that whenever - (void)request:(ASIHTTPRequest *)request didReceiveData:(NSData *)data: was called the cache won't saved. Any Idea?

Community
  • 1
  • 1
Lunayo
  • 538
  • 7
  • 32

1 Answers1

0

I used the same thing. Only difference is that I had to set the following selectors:

[_conn setDidFailSelector:@selector(downloadDidFail:)];
[_conn setDidFinishSelector:@selector(downloadDidFinish:)];
[_conn setDidStartSelector:@selector(downloadDidStart:)];

And not implement any of the other delegate methods specified as optional in the ASIHTTPRequestDelegate protocol. Now the download works perfectly and will call the set selectors when needed.

Jake
  • 3,973
  • 24
  • 36
  • But I need to track the download progress by byte so I need the [data length] from delegate request didReceiveData:. – Lunayo Jun 21 '11 at 03:58
  • If you know the total size (which you are able to), you can attach a custom progress delegate to receive progress and calculate that to bytes downloaded. – Jake Jun 21 '11 at 08:12
  • yes, it worked. I used the custom progress delegate. Thanks a lot! – Lunayo Jun 21 '11 at 08:24