I have a WebView that is loading a webpage. I want to save all the images loaded in the webpage, but I want to save them as each image is finished downloading through the delegate method:
-(void) webView:(WebView *)sender resource:(id)identifier didFinishLoadingFromDataSource:(WebDataSource *)dataSource
How would I do this? I just want to avoid the situation where I grab the image src’s and then redownload the images. Maybe my approach is wrong? Maybe save the images through [NSURLCache sharedURLCache]? Any help is greatly appreciated! Thanks!
This SO answer helped out a lot in giving me some breakthroughs for my final solution. I ended up executing some javascript to grab the src attribute from the img tag. Then, every time the
-(void) webView:(WebView *)sender resource:(id)identifier didFinishLoadingFromDataSource:(WebDataSource *)dataSourcemethod is called, it checks for[dataSource subresourceForURL:url]. If it returns true, then it performs the save. Here’s the full code:Hope this helps someone!