NSCloneCommand Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in OS X v10.0 and later.
Companion guide
Declared in
NSScriptStandardSuiteCommands.h

Overview

An instance of NSCloneCommand clones the specified scriptable object or objects (such as words, paragraphs, images, and so on) and inserts them in the specified location, or the default location if no location is specified. The cloned scriptable objects typically correspond to objects in the application, but aren’t required to. This command corresponds to AppleScript’s duplicate command.

NSCloneCommand is part of Cocoa’s built-in scripting support. It works automatically to support the duplicate command through key-value coding. Most applications don’t need to subclass NSCloneCommand or invoke its methods.

When an instance of NSCloneCommand is executed, it clones the specified objects by sending them copyWithZone: messages.

Tasks

Working with Specifiers

Instance Methods

keySpecifier

Returns a specifier for the object or objects to be cloned.

- (NSScriptObjectSpecifier *)keySpecifier
Return Value

A specifier for the object or objects to be cloned.

Discussion

For example, the specifier may indicate that a document’s third rectangle should be cloned. The returned specifier is valid only in the context of the NSCloneCommand object; for example, if you send the specifier a containerSpecifier message, the result is nil.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSScriptStandardSuiteCommands.h

setReceiversSpecifier:

Sets the receiver’s object specifier;.

- (void)setReceiversSpecifier:(NSScriptObjectSpecifier *)receiversRef
Parameters
receiversRef

The object specifier for the receiver.

Discussion

When evaluated, the specifier indicates the receiver or receivers of the clone command.

This method overrides setReceiversSpecifier: in NSScriptCommand. It performs the same function as the overridden method, with a critical difference: it causes the container specifier part of the passed-in object specifier to become the receiver specifier of the command, and the key part of the passed-in object specifier to become the key specifier. If, for example, receiversRef is a specifier for the third rectangle of the first document, the receiver specifier is the first document while the key specifier is the third rectangle.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSScriptStandardSuiteCommands.h