Mac Developer Library

Developer

Foundation Framework Reference NSCloneCommand Class Reference

Options
Deployment Target:

On This Page
Language:

NSCloneCommand

Inheritance


Conforms To


Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

Availability


Available in OS X v10.0 and later.

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.

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

    Declaration

    Swift

    var keySpecifier: NSScriptObjectSpecifier! { get }

    Objective-C

    @property(readonly, retain) 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.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Sets the receiver’s object specifier;.

    Declaration

    Swift

    func setReceiversSpecifier(_ receiversRef: NSScriptObjectSpecifier)

    Objective-C

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

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.