Instance Method

sharingServicePicker(_:sharingServicesForItems:proposedSharingServices:)

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

Declaration

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

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];