Method argument and return types that are Objective-C objects will be converted to appropriate types for the scripting environment. For example:
nilis converted to undefined.
NSArrayobjects will be mapped to special read-only arrays.
WebUndefinedwill be converted to undefined.
WebScriptObjectinstances will be unwrapped for the scripting environment.
Instances of all other classes will be wrapped before being passed to the script, and unwrapped as they return to Objective-C. Primitive types such as
Access to an object’s attributes, such as instance variables, is managed by key-value coding (KVC). The KVC methods
valueForKey: are used to access the attributes of an object from the scripting environment. Additionally, the scripting environment can attempt any number of attribute requests or method invocations that are not exported by your class. You can manage these requests by overriding the
valueForUndefinedKey: methods from the key-value coding protocol.
Exceptions can be raised from the scripting environment by sending a
throwException(_:) message to the relevant
WebScriptObject instance. The method raising the exception must be within the scope of the script invocation.