Web view resource load delegates implement this protocol to be notified on the progress of loading individual resources. Note that there can be hundreds of resources, such as images and other media, per page. So, if you just want to get page loading status see the WebFrameLoadDelegate protocol.


protocol WebResourceLoadDelegate


There’s a separate client request and server response made for each resource on a page. By implementing the webView(_:identifierForInitialRequest:from:) method, resource load delegates provide a tracking object used to identify individual resources in subsequent calls to delegate methods. Delegates are then notified when resource loading starts, when data is incrementally received, when any load errors occur, and when the load is complete. Delegates may also change a request before it is sent. In some cases, depending on the page content and server redirects, methods defined in this protocol may be invoked multiple times (see individual method descriptions for more details). All the methods in this protocol are optional.


Setting Identifiers

func webView(WebView!, identifierForInitialRequest: URLRequest!, from: WebDataSource!) -> Any!

Returns an identifier object used to track the progress of loading a single resource.

Authenticating Resources

func webView(WebView!, resource: Any!, didReceive: URLAuthenticationChallenge!, from: WebDataSource!)

Invoked when an authentication challenge has been received for a resource.

func webView(WebView!, resource: Any!, didCancel: URLAuthenticationChallenge!, from: WebDataSource!)

Invoked when an authentication challenge for a resource was canceled.


Inherits From

See Also

Loading Resources (Legacy)

class WebResource

A WebResource object represents a downloaded URL. It encapsulates the data of the download as well as other resource properties such as the URL, MIME type, and frame name.