Mac Developer Library

Developer

AppKit Framework Reference NSServicesMenuRequestor Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSServicesMenuRequestor

Inheritance


Not Applicable

Conforms To


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.9 and later.

This informal protocol consists of two methods, writeSelectionToPasteboard:types: and readSelectionFromPasteboard:. The first method provides data to a remote service, and the second receives any data the remote service might send back. Both respond to messages that are generated when the user chooses a command from the Services menu.

  • readSelectionFromPasteboard: - readSelectionFromPasteboard: Available in OS X v10.0 through OS X v10.8

    Reads data from the pasteboard and uses it to replace the current selection.

    Declaration

    Objective-C

    - (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard

    Parameters

    pboard

    The pasteboard containing the data to read.

    Return Value

    YEStrue if your implementation was able to read the pasteboard data successfully; otherwise, NOfalse.

    Discussion

    You implement this method to replace your application's current selection (that is, the text or objects that are currently selected) with the data on the pasteboard. The data would have been placed in the pasteboard by another application in response to a remote message from the Services menu. A readSelectionFromPasteboard: message is sent to the same object that previously received a writeSelectionToPasteboard:types: message.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 through OS X v10.8.

  • writeSelectionToPasteboard:types: - writeSelectionToPasteboard:types: Available in OS X v10.0 through OS X v10.8

    Writes the current selection to the pasteboard.

    Declaration

    Objective-C

    - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray *)types

    Parameters

    pboard

    The pasteboard to receive your data.

    types

    An array of NSString objects listing the types of data that you should write to the pasteboard. You should write data to the pasteboard for as many of the types as you support.

    Return Value

    YEStrue if your implementation was able to write one or more types to the pasteboard; otherwise, NOfalse.

    Discussion

    A writeSelectionToPasteboard:types: message is sent to the first responder when the user chooses a command from the Services menu, but only if the receiver didn’t return nil to a previous validRequestorForSendType:returnType: message.

    After your method writes the data to the pasteboard, a remote message is sent to the application that provides the service the user requested. If the service provider supplies return data to replace the selection, the first responder will then receive a readSelectionFromPasteboard: message.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 through OS X v10.8.

    See Also

    validRequestorForSendType:returnType: (NSResponder)