<!--
{
  "documentType" : "article",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/webplugin",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "WebPlugIn"
}
-->

# WebPlugIn

The `WebPlugIn` informal protocol defines methods that enable interaction between an application using the WebKit framework and any WebKit-based plug-ins it may use.

## Topics

### Accessing the Scripting Environment

[`var objectForWebScript: Any!`](/documentation/ObjectiveC/NSObject-swift.class/objectForWebScript)

Returns an object that exposes the plug-in’s scripting interface.

### Using Plug-in State Information

[`func webPlugInSetIsSelected(Bool)`](/documentation/ObjectiveC/NSObject-swift.class/webPlugInSetIsSelected(_:))

Controls plug-in behavior based on its selection.

### Controlling the Plug-in

[`func webPlugInDestroy()`](/documentation/ObjectiveC/NSObject-swift.class/webPlugInDestroy())

Prepares the plug-in for deallocation.

[`func webPlugInInitialize()`](/documentation/ObjectiveC/NSObject-swift.class/webPlugInInitialize())

Initializes the plug-in.

[`func webPlugInStart()`](/documentation/ObjectiveC/NSObject-swift.class/webPlugInStart())

Tells the plug-in to start normal operation.

[`func webPlugInStop()`](/documentation/ObjectiveC/NSObject-swift.class/webPlugInStop())

Tells the plug-in to stop normal operation.

### Main resource messages

[`func webPlugInMainResourceDidFailWithError((any Error)!)`](/documentation/ObjectiveC/NSObject-swift.class/webPlugInMainResourceDidFailWithError(_:))

Invoked when an error occurs loading the main resource.

[`func webPlugInMainResourceDidFinishLoading()`](/documentation/ObjectiveC/NSObject-swift.class/webPlugInMainResourceDidFinishLoading())

Invoked when the connection successfully finishes loading data.

[`func webPlugInMainResourceDidReceive(Data!)`](/documentation/ObjectiveC/NSObject-swift.class/webPlugInMainResourceDidReceive(_:)-5b6f6)

Invoked when the connection loads data incrementally.

[`func webPlugInMainResourceDidReceive(URLResponse!)`](/documentation/ObjectiveC/NSObject-swift.class/webPlugInMainResourceDidReceive(_:)-6x7b9)

Invoked when the connection receives sufficient data to construct the URL response for its request.



---

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)