0

I was looking at this posting where the op says he is canceling requests in web view:shouldStartLoadWithRequest:

How to do authentication in UIWebView properly?

How is that possible? I don't see any API on NSURLRequest to cancel it. I know its possible to cancel an NSURLConnection, if the op meant to say NSURLConnection in the posting instead of NSURLRequest, then how do you obtain the underlying NSURLConnection from within a UIWebView?

Community
  • 1
  • 1
Gruntcakes
  • 37,738
  • 44
  • 184
  • 378

1 Answers1

2

An NSURLRequest isn't itself a process to be canceled, so there's no API for it. When a UIWebView sends its delegate a webView:shouldStartLoadWithRequest: message, it's asking whether it should start the process of fetching data from / posting data to a URL -- the NSURLRequest parameter is an object which simply describes that proposed action, not the object which performs it. (If UIWebView is using an underlying NSURLConnection, it hasn't created it yet; that's what it's asking to do.) "Canceling the request" is simply a matter of returning NO from that method.

rickster
  • 124,678
  • 26
  • 272
  • 326
  • @Mr. Peckington: True, writing is on the [wall](http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIWebViewDelegate_Protocol/Reference/Reference.html) – Rok Jarc Mar 20 '12 at 00:24