<!--
{
  "availability" : [
    "macOS: 10.3.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WebView-swift.class/registerClass(_:representationClass:forMIMEType:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(cs)WebView(cm)registerViewClass:representationClass:forMIMEType:"
  },
  "title" : "registerClass(_:representationClass:forMIMEType:)"
}
-->

# registerClass(_:representationClass:forMIMEType:)

Specifies the view and representation objects to be used for specific MIME types.

```
class func registerClass(_ viewClass: AnyClass!, representationClass: AnyClass!, forMIMEType MIMEType: String!)
```

## Parameters

`viewClass`

A class conforming to the [`WebDocumentView`](/documentation/WebKit/WebDocumentView) protocol that displays the specified MIME types.

`representationClass`

The class conforming to [`WebDocumentRepresentation`](/documentation/WebKit/WebDocumentRepresentation) protocol that represents the specified MIME types.

`MIMEType`

The MIME type of the content.

    This may be a primary MIME type or subtype. For example, if     `MIMEType`     is “video/” the specified view and representation objects are used for all video types. More specific subtype mappings, such as “image/gif”, takes precedence over primary type matching, such as “image/”.

## Discussion

After invoking this method, when `MIMEType` content is encountered, instances of `representationClass` and `viewClass` are created to handle and display it.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)