Instance Method


Calls the named JavaScript method on the value.


func invokeMethod(_ method: String!, withArguments arguments: [Any]!) -> JSValue!



The name of a method on the value; that is, of a field whose contents are a function value.


The parameters to pass to the method. The objects in this array must be other JSValue objects or objects that can be converted to JavaScript values using the methods listed in Creating JavaScript Values.

Return Value

The result of calling the value as a constructor, or nil if the value cannot be treated as a JavaScript constructor.


Calling this Objective-C method first uses the forProperty(_:) method to look up the named field of the JavaScript value. Then, JavaScriptCore treats that field’s contents as a JavaScript function and sets the JavaScript this keyword to refer to this JSValue instance.

See Also

Working with Function and Constructor Values

func call(withArguments: [Any]!) -> JSValue!

Invokes the value as a JavaScript function.

func construct(withArguments: [Any]!) -> JSValue!

Invokes the value as a JavaScript constructor.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software