NSSharingServicePickerDelegate Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in OS X v10.8 and later.
Declared in
NSSharingService.h
Related sample code

Overview

The NSSharingServicePickerDelegate protocol allows customization of the service picker behavior.

See NSSharingServicePicker Class Reference for more information.

Tasks

Proposed Sharing Services

Customizing Behavior

Instance Methods

sharingServicePicker:delegateForSharingService:

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

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

Availability
  • Available in OS X v10.8 and later.
Declared In
NSSharingService.h

sharingServicePicker:didChooseSharingService:

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

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

Availability
  • Available in OS X v10.8 and later.
Declared In
NSSharingService.h

sharingServicePicker:sharingServicesForItems:proposedSharingServices:

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

- (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];
Availability
  • Available in OS X v10.8 and later.
Declared In
NSSharingService.h