NSScriptKeyValueCoding

A collection of methods that provide additional capabilities for working with key-value coding.

Overview

Cocoa scripting takes advantage of key-value coding to get and set information in scriptable objects. The methods in this category provide additional capabilities for working with key-value coding, including getting and setting key values by index in multi-value keys and coercing (or converting) a key value. Additional methods allow the implementer of a scriptable container class to provide fast access to elements that are being referenced by name and unique ID.

Because Cocoa scripting invokes setValue(_:forKey:) and mutableArrayValue(forKey:), changes to model objects made by AppleScript scripts are observable using automatic key-value observing.

Topics

Indexed access

func insertValue(Any, at: Int, inPropertyWithKey: String)

Inserts an object at the specified index in the collection specified by the passed key.

func removeValue(at: Int, fromPropertyWithKey: String)

Removes the object at the specified index from the collection specified by the passed key.

func replaceValue(at: Int, inPropertyWithKey: String, withValue: Any)

Replaces the object at the specified index in the collection specified by the passed key.

func value(at: Int, inPropertyWithKey: String)

Retrieves an indexed object from the collection specified by the passed key.

Access by name, key, or ID

func insertValue(Any, inPropertyWithKey: String)

Inserts an object in the collection specified by the passed key.

func value(withName: String, inPropertyWithKey: String)

Retrieves a named object from the collection specified by the passed key.

func value(withUniqueID: Any, inPropertyWithKey: String)

Retrieves an object by ID from the collection specified by the passed key.

Coercion

func coerceValue(Any?, forKey: String)

Uses type info from the class description and NSScriptCoercionHandler to attempt to convert value for key to the proper type, if necessary.

Constants

NSScriptKeyValueCoding Exception Names

Exceptions raised by key-value coding methods.

See Also

NSObject Script Support

NSComparisonMethods

A collection of default comparison methods useful for performing specifier tests.

NSScriptingComparisonMethods

A collection of methods useful for comparing script objects.

NSScriptObjectSpecifiers

A collection of methods providing additional object specifier functionality.

class NSScriptCoercionHandler

A mechanism for converting one kind of scripting data to another.

class NSScriptExecutionContext

The context in which the current script command is executed.