Mac Developer Library

Developer

AppKit Framework Reference NSSharingServicePickerDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSSharingServicePickerDelegate

Inheritance


Not Applicable

Conforms To


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.8 and later.

The NSSharingServicePickerDelegate protocol allows customization of the service picker behavior.

See NSSharingServicePicker Class Reference for more information.

  • Invoked to allow the delegate to customize exactly what appears in the sharing service picker before it is presented.

    Declaration

    Swift

    optional func sharingServicePicker(_ sharingServicePicker: NSSharingServicePicker, sharingServicesForItems items: [AnyObject], proposedSharingServices proposedServices: [AnyObject]) -> [AnyObject]

    Objective-C

    - (NSArray *)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker sharingServicesForItems:(NSArray *)items proposedSharingServices:(NSArray *)proposedServices

    Parameters

    sharingServicePicker

    The sharing service picker.

    items

    The items to share.

    proposedServices

    The proposed services to share the content.

    Return Value

    The sharing services to use.

    Discussion

    The delegate can reorder, remove default services or add custom services before the picker is presented. It's possible to add custom services by mutating the proposedSharingServices array and adding new NSSharingService instances.

    The following is an example:

    • NSMutableArray *sharingServices = [proposedServices mutableCopy];
    • NSSharingService * customService = [[[NSSharingService alloc] initWithTitle:@"Service Title"
    • image:image alternateImage:alternateImage
    • handler:^{
    • [self doCustomServiceWithItems:items];
    • }] autorelease];
    • [sharingServices addObject:customService];
    • return [sharingServices autorelease];

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.8 and later.

  • Invoked to provide the delegate to the sharing service when the user has selected a service.

    Declaration

    Swift

    optional func sharingServicePicker(_ sharingServicePicker: NSSharingServicePicker, delegateForSharingService sharingService: NSSharingService) -> NSSharingServiceDelegate?

    Objective-C

    - (id<NSSharingServiceDelegate>)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker delegateForSharingService:(NSSharingService *)sharingService

    Parameters

    sharingServicePicker

    The sharing service picker.

    sharingService

    The selected sharing service.

    Return Value

    An object that implements the NSSharingServiceDelegate protocol the sharing service should use for this item’s transfer.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.8 and later.

  • Invoked when the user has selected a service and before it is executed.

    Declaration

    Swift

    optional func sharingServicePicker(_ sharingServicePicker: NSSharingServicePicker, didChooseSharingService service: NSSharingService)

    Objective-C

    - (void)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker didChooseSharingService:(NSSharingService *)service

    Parameters

    sharingServicePicker

    The sharing service picker.

    service

    The sharing service the user selected. Invoked to give the delegate to the sharing service that is about to be executed.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.8 and later.