WebDataSource Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/WebKit.framework |
| Availability | Available in OS X v10.2 with Safari 1.0 and later. Available in OS X v10.2.7 and later. |
| Companion guide | |
| Declared in | WebDataSource.h |
Overview
WebDataSource encapsulates the web content to be displayed in a web frame view. A WebDataSource object has a representation object, conforming to the WebDocumentRepresentation protocol, that holds the data in an appropriate format depending on the MIME type. You can extend WebKit to support new MIME types by implementing your own view and representation classes, and specifying the mapping between them using the registerViewClass:representationClass:forMIMEType: WebView class method.
WebDataSource objects have an associated initial request, possibly a modified request, and a response object. Since the data source may be in the process of being loaded, you should check the state of a data source using the isLoading method before accessing its data. Use the data method to get the raw data. Use the representation method to get the actual representation object and query it for more details.
Tasks
Initializing an Instance
Querying Page Data and State
Getting the Request and Response
Getting the Web Frame
Getting an Unreachable URL
Getting a Web Archive
Accessing Subresources
Instance Methods
addSubresource:
Adds a resource to the data source’s list of subresources.
Parameters
- subresource
The resource to add to the data source.
Discussion
If the data source needs to reload the resource’s URL, it loads the data from subresource instead of the network. For example, use this method if you want to use a previously downloaded image rather than accessing the network to reload a resource. If the data source already has a resource with the same URL as subresource, then this method replaces it.
Availability
- Available in OS X v10.3.9 and later.
See Also
Declared In
WebDataSource.hdata
Returns the raw data that represents the data source’s content.
Return Value
The data used to display the webpage or nil if the data source hasn’t loaded any data. The format of the data is dependent on the data source’s MIME type (obtained from the response).
Discussion
Use the isLoading method to test if a data source is in the process of loading.
Availability
- Available in OS X v10.2 with Safari 1.0 and later.
- Available in OS X v10.2.7 and later.
See Also
Declared In
WebDataSource.hinitialRequest
Returns a reference to the original request that was used to load the web content.
Return Value
The initial request.
Availability
- Available in OS X v10.2 with Safari 1.0 and later.
- Available in OS X v10.2.7 and later.
See Also
Declared In
WebDataSource.hinitWithRequest:
initializes a data source with a URL request.
Parameters
- request
The URL request used to load the web content.
Return Value
The initialized web data source.
Discussion
This method is the designated initializer for WebDataSource objects. Normally, WebFrame objects create their data sources, so you should not invoke this method directly.
Availability
- Available in OS X v10.2 with Safari 1.0 and later.
- Available in OS X v10.2.7 and later.
Declared In
WebDataSource.hisLoading
Returns whether the data source is loading its content.
Return Value
YES if the data source is in the process of loading its content; otherwise, NO.
Availability
- Available in OS X v10.2 with Safari 1.0 and later.
- Available in OS X v10.2.7 and later.
See Also
Declared In
WebDataSource.hmainResource
Creates and returns a WebResource object representing the data source.
Return Value
A web resource representing the data source. The contents returned are based on the original downloaded data. You can use the returned value to create a WebArchive object instead of using the webArchive method.
Availability
- Available in OS X v10.3.9 and later.
Declared In
WebDataSource.hpageTitle
Returns the title of the data source’s page.
Return Value
The page title or nil if the page has no title or the page title hasn’t been loaded yet.
Discussion
The associated web view notifies its frame load delegate when the page title is loaded by invoking the webView:didReceiveTitle:forFrame: delegate method.
Availability
- Available in OS X v10.2 with Safari 1.0 and later.
- Available in OS X v10.2.7 and later.
See Also
Declared In
WebDataSource.hrepresentation
Returns the data source’s representation depending on its MIME type.
Return Value
The data source’s representation or nil if the data source is in the process of being loaded and this method is invoked before loading is complete.
Discussion
You can specify the mapping between a representation and MIME type using the registerViewClass:representationClass:forMIMEType: WebView class method.
Availability
- Available in OS X v10.2 with Safari 1.0 and later.
- Available in OS X v10.2.7 and later.
See Also
Declared In
WebDataSource.hrequest
Returns the request that was used to create the data source.
Return Value
The request used to load the web content. This URL may be different from the original request returned by the initialRequest method.
Discussion
A web view’s resource load delegate may modify requests by implementing the webView:resource:willSendRequest:redirectResponse:fromDataSource: method.
Availability
- Available in OS X v10.2 with Safari 1.0 and later.
- Available in OS X v10.2.7 and later.
See Also
Declared In
WebDataSource.hresponse
Returns the associated WebResourceResponse object for this data source.
Return Value
The associated WebResourceResponse object or nil if a response has not been received yet..
Availability
- Available in OS X v10.2 with Safari 1.0 and later.
- Available in OS X v10.2.7 and later.
See Also
Declared In
WebDataSource.hsubresourceForURL:
Returns a subresource for the given URL.
Parameters
- URL
The subresource’s URL.
Return Value
The subresource for URL or nil if the data source hasn’t finished downloading the subresource.
Availability
- Available in OS X v10.3.9 and later.
See Also
Declared In
WebDataSource.hsubresources
Returns the data source’s subresources that have finished downloading.
Return Value
An array of the data source’s loaded subresources.
Availability
- Available in OS X v10.3.9 and later.
See Also
Declared In
WebDataSource.htextEncodingName
Returns the text encoding for the data source’s web view, if set, or the text encoding of the response.
Return Value
The text encoding.
Availability
- Available in OS X v10.2 with Safari 1.0 and later.
- Available in OS X v10.2.7 and later.
Declared In
WebDataSource.hunreachableURL
Returns the data source’s unreachable URL.
Return Value
The unreachable URL if it exists; otherwise, nil.
Discussion
The data source has an unreachable URL if it was created using the loadAlternateHTMLString:baseURL:forUnreachableURL: WebFrame method.
Availability
- Available in OS X v10.3.9 and later.
Declared In
WebDataSource.hwebArchive
Returns a web archive representing the data source, its subresources, and subframes.
Return Value
A web archive representing the data source constructed using the original downloaded data. In the case of HTML, if the current content is preferred, then send webArchive to the appropriate DOM object.
Availability
- Available in OS X v10.3.9 and later.
See Also
Declared In
WebDataSource.hwebFrame
Returns the web frame that represents this data source.
Return Value
The associated web frame.
Availability
- Available in OS X v10.2 with Safari 1.0 and later.
- Available in OS X v10.2.7 and later.
Declared In
WebDataSource.h© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-08-17)