Class

WebScriptObject

A WebScriptObject object is an Objective-C wrapper for a scripting object passed to your application from the scripting environment.

Overview

You can not create a WebScriptObject object directly. You get a window WebScriptObject object by sending windowScriptObject to your WebView object.

You can use key-value coding methods—for example, setValue:forKey: and valueForKey:—to get and set properties of a WebScriptObject object. You can also access properties by index using the setWebScriptValueAt(_:value:) and webScriptValue(at:) methods. Use the removeWebScriptKey(_:) method to remove a scripting object property.

Not all properties and methods of a class are exported. Use the setValue(_:forUndefinedKey:) and value(forUndefinedKey:) methods to intercept access to properties that are not exported. Similarly, use the invokeUndefinedMethod(fromWebScript:withArguments:) method to intercept method invocations that are not exported.

If you want access to properties and methods defined in your own classes, use the methods in the WebScripting informal protocol to specify the properties and methods the class should export to WebKit’s JavaScript environment.

Use the callWebScriptMethod(_:withArguments:) and evaluateWebScript(_:) methods to execute scripts in the scripting environment.

Symbols

Getting and setting properties

func jsObject()

Returns the JavaScript object corresponding to the receiver.

func removeWebScriptKey(String!)

Removes a property from a scripting environment.

func webScriptValue(at: UInt32)

Returns the value of a property at the specified index.

func setWebScriptValueAt(UInt32, value: Any!)

Sets the value of a property at the specified index.

Executing scripts

func callWebScriptMethod(String!, withArguments: [Any]!)

Returns the result of executing a method in the scripting environment.

func evaluateWebScript(String!)

Returns the result of evaluating a script in the scripting environment.

Raising exceptions

class func throwException(String!)

Raises an exception in the current script execution context.

func setException(String!)

Raises a scripting environment exception in the context of the current object.

Getting a string representation

func stringRepresentation()

Returns a string representation of the receiver.

Instance Methods

Relationships

Inherits From

Conforms To