NSScriptKeyValueCoding

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 multivalue 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.

Overview

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

Symbols

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

NSScriptKeyValueCoding defines the following exception.