<!--
{
  "availability" : [
    "macOS: 10.8.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSSharingService/init(title:image:alternateImage:handler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSSharingService(im)initWithTitle:image:alternateImage:handler:"
  },
  "title" : "init(title:image:alternateImage:handler:)"
}
-->

# init(title:image:alternateImage:handler:)

Creates a custom sharing service object.

```
init(title: String, image: NSImage, alternateImage: NSImage?, handler block: @escaping () -> Void)
```

## Parameters

`title`

The custom sharing service name.

`image`

The image that represents the sharing service

`alternateImage`

The alternate image that represents the sharing service

`block`

The block that actually interacts with the service.

## Return Value

An instance of the custom sharing object.

## Discussion

Custom sharing services can be added to the [`NSSharingServicePicker`](/documentation/AppKit/NSSharingServicePicker) with the [`sharingServicePicker(_:sharingServicesForItems:proposedSharingServices:)`](/documentation/AppKit/NSSharingServicePickerDelegate/sharingServicePicker(_:sharingServicesForItems:proposedSharingServices:)) delegate method.

When implementing this method, consider subclassing `NSSharingService` so the [`canPerform(withItems:)`](/documentation/AppKit/NSSharingService/canPerform(withItems:)) and [`sharingServices(forItems:)`](/documentation/AppKit/NSSharingService/sharingServices(forItems:)) can provide accurate results.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)