Mac Developer Library

Developer

AppKit Framework Reference NSSharingServicePickerDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSSharingServicePickerDelegate

The NSSharingServicePickerDelegate protocol allows customization of the service picker behavior.

See NSSharingServicePicker Class Reference for more information.

Inheritance


Not Applicable

Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.8 and later.
  • 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.