Reputation: 2801
I have a method that created a NSURLRequest. If I load this NSURLRequest in a UIWebView, there are some redirections that I catch with - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
.
How can I intercept this redirections without load my request in a UIWebView ? (I do not want it at all)
Upvotes: 3
Views: 2598
Reputation: 7118
You can subclass NSURLCache
in order to intercept any url requests.
This example: http://cocoawithlove.com/2010/09/substituting-local-data-for-remote.html demonstrates using a subclass to load local files in place of remote files, but you should also be able to use a similar subclass to cancel requests or perform other actions you need.
Upvotes: 0
Reputation: 90641
Well, you have to tell us how you're loading it to begin with. Are you using NSURLConnection
? Then use the -connection:willSendRequest:redirectResponse:
delegate method. Be sure to read the docs to understand when it will be called. It is often called just because the framework tweaked your request, before actually communicating with anything, so not every invocation is a redirect.
Upvotes: 3
Reputation: 8546
if i understand well you want to catch the request and not load it in the webview. If that's what you want to do, just make your method return NO.
- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType.
Upvotes: 1