开发者

Check if file download (method) is completed

This is probably a pretty stupid question, but I haven't been able to find the answer because I don't really know what I'm looking for.

Basically I want to know when the restClient method (which downloads a remote file) is done, because I want t开发者_StackOverflow社区o wait for that before I want webView to load the file: [webView loadRequest:request];

What would be the best way to do this?

[self.restClient loadFile:[NSString stringWithString:filePath] intoPath:[NSString stringWithString:localPath]]; 

NSURL *url = [NSURL fileURLWithPath:localPath];
NSURLRequest *request = [NSURLRequest requestWithURL:url];

[webView loadRequest:request];


Set the delegate on you restClient, probably to the current instance, and perform the loadRequest in the loadedFile method:

- (void)restClient:(DBRestClient*)client loadedFile:(NSString*)destPath
{
    NSURL *url = [NSURL fileURLWithPath:destPath];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];

    [webView loadRequest:request];
}


What is restClient (type)? It depends on if the download is done on a background thread (most likely), in which case there should be a delegate callback.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜