A WKUserContentController object provides a way for JavaScript to post messages and inject user scripts to a web view.


class WKUserContentController : NSObject


Adding Message Handlers

Adding and Removing User Scripts

func removeAllUserScripts()

Removes all associated user scripts.

func removeScriptMessageHandler(forName: String)

Removes a script message handler.

var userScripts: [WKUserScript]

The user scripts associated with the user content controller.

Adding and Removing Content Rules

func add(WKContentRuleList)

Adds a list of content rules.

func remove(WKContentRuleList)

Removes a rules list.

func removeAllContentRuleLists()

Removes all rules lists.

class WKContentRuleList

A compiled list of rules to apply to web content.


Inherits From

See Also


class WKScriptMessage

A WKScriptMessage object contains information about a message sent from a webpage.

class WKUserScript

A WKUserScript object represents a script that can be injected into a webpage.

protocol WKScriptMessageHandler

A class conforming to the WKScriptMessageHandler protocol provides a method for receiving messages from JavaScript running in a webpage.