scriptingValue(for:)
Given an object specifier, returns the specified object or objects in the receiving container.
Declaration
func scriptingValue(for objectSpecifier: NSScriptObjectSpecifier) -> Any?Parameters
- objectSpecifier:
An object specifier to be evaluated.
Return Value
The specified object or objects in the receiving container.
Discussion
This method might successfully return an object, an array of objects, or nil, depending on the kind of object specifier. Because nil is a valid return value, failure is signaled by invoking the object specifier’s setEvaluationError: method before returning.
Discussion
You can override this method to customize the evaluation of object specifiers without requiring that the scripting container make up indexes for contained objects that don’t naturally have indexes (as can be the case if you implement indicesOfObjects(byEvaluatingObjectSpecifier:) instead).
Your override of this method doesn’t need to also invoke any of the NSScriptCommand error signaling methods, though it can, to record very specific information. The NSUnknownKeySpecifierError and NSInvalidIndexSpecifierError numbers are special, in that Cocoa may continue evaluating an outer specifier if they’re encountered, for the convenience of scripters.