Skip to content

Instantly share code, notes, and snippets.

@Daij-Djan
Last active July 28, 2017 08:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Daij-Djan/5187069 to your computer and use it in GitHub Desktop.
Save Daij-Djan/5187069 to your computer and use it in GitHub Desktop.
Response headers / statusCode from a UIWebView (using workaround till the webview gets extended!)
@implementation DDViewController
- (void)viewDidAppear:(BOOL)animated {
NSURL *u = [NSURL URLWithString:@"http://www.google.de"];
NSURLRequest *r = [NSURLRequest requestWithURL:u];
[self.webView loadRequest:r];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
NSCachedURLResponse *resp = [[NSURLCache sharedURLCache] cachedResponseForRequest:webView.request];
NSLog(@"%@",[(NSHTTPURLResponse*)resp.response allHeaderFields]);
}
@end
@Daij-Djan
Copy link
Author

disclaimer only works for cacheable urls!

@tomasdev
Copy link

any workaround for non-cacheable urls?

@jonahbohlmann
Copy link

need a workaround too. Sometimes cachedResponseForRequest return nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment