Mac Developer Library

Developer

WebKit Framework Reference WebDocumentRepresentation Protocol Reference

Options
Deployment Target:

On This Page
Language:

WebDocumentRepresentation

This protocol is adopted by document representation classes that handle specific MIME types. You can implement your own document view classes and document representation classes to render data for specific MIME types, and register those classes using the WebFrame registerViewClass:representationClass:forMIMEType: method.

Inheritance


Not Applicable

Import Statement


import WebKit @import WebKit;

Availability


Available in OS X v10.2 with Safari 1.0 and later.
Available in OS X v10.2.7 and later.
  • Sets the receiver’s data source.

    Declaration

    Swift

    func setDataSource(_ dataSource: WebDataSource!)

    Objective-C

    - (void)setDataSource:(WebDataSource *)dataSource

    Parameters

    dataSource

    The data source to associate with the object.

    Discussion

    This method is invoked soon after the document representation is created.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Invoked when a data source has received some data.

    Declaration

    Swift

    func receivedData(_ data: NSData!, withDataSource dataSource: WebDataSource!)

    Objective-C

    - (void)receivedData:(NSData *)data withDataSource:(WebDataSource *)dataSource

    Parameters

    data

    An NSData object containing the data received.

    dataSource

    A WebDataSource object that identifies the request that generated this data.

    Discussion

    Data is loaded incrementally, so this method may be invoked multiple times. The receiver is responsible for accumulating this data.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Invoked when a data source receives an error loading its content.

    Declaration

    Swift

    func receivedError(_ error: NSError!, withDataSource dataSource: WebDataSource!)

    Objective-C

    - (void)receivedError:(NSError *)error withDataSource:(WebDataSource *)dataSource

    Parameters

    error

    An NSError object that indicates what error occurred.

    dataSource

    A WebDataSource object that identifies the request that caused this error.

    Discussion

    The error argument contains details on the error that occurred.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Invoked when a data source finishes loading its content.

    Declaration

    Swift

    func finishedLoadingWithDataSource(_ dataSource: WebDataSource!)

    Objective-C

    - (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource

    Parameters

    dataSource

    A WebDataSource object that identifies the request that finished loading.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Returns whether the receiver can provide content source.

    Declaration

    Swift

    func canProvideDocumentSource() -> Bool

    Objective-C

    - (BOOL)canProvideDocumentSource

    Return Value

    YEStrue if the receiver can provide source for the document content (for example, HTML source), NOfalse otherwise.

    Discussion

    The receiver should return YEStrue only if it makes sense for someone to view the source of the document in question. For example, a web view returns NOfalse if the content is an image, was produced by a plug-in, or contains text content already.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Returns the receiver’s source as text.

    Declaration

    Swift

    func documentSource() -> String!

    Objective-C

    - (NSString *)documentSource

    Return Value

    Returns the document source associated with the receiver or nil if the source cannot be provided.

    Discussion

    For example, for HTML documents, the receiver should return the HTML source.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Returns the receiver’s document title.

    Declaration

    Swift

    func title() -> String!

    Objective-C

    - (NSString *)title

    Return Value

    The title associated with the receiving document object.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.