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

# NSSharingService

An object that facilitates the sharing of content with social media services, or with apps like Mail or Safari.

```
class NSSharingService
```

## Overview

An [`NSSharingService`](/documentation/AppKit/NSSharingService) object provides a consistent user experience for sharing items—<doc://com.apple.documentation/documentation/Foundation/NSURL> objects, <doc://com.apple.documentation/documentation/Foundation/NSString> objects, [`NSImage`](/documentation/AppKit/NSImage) objects, video (through file URLs), of any object that implements the [`NSPasteboardWriting`](/documentation/AppKit/NSPasteboardWriting) protocol—in macOS.

For any item or group of items, the [`NSSharingService`](/documentation/AppKit/NSSharingService) displays a sheet with the content to share. A sharing service can create a post on a social network like Twitter or Facebook, send a message by email or iMessage, upload videos to viewing services, or send a file using AirDrop.

You can use [`NSSharingService`](/documentation/AppKit/NSSharingService) objects directly in your app. The following example shows how to create a button that shares content directly to a social media service.

```objc
- (void)awakeFromNib
{
    NSSharingService * service = [NSSharingService sharingServiceNamed:NSSharingServiceNamePostOnTwitter];
    [myShareOnTwitterButton setTitle:service.title];
    [myShareOnTwitterButton setEnabled:[service canPerformWithItems:nil]];
}
 
 
- (IBAction)shareOnTwitter:(id)sender
{
    // Items to share
    NSAttributedString *text = [self.textView attributedString];
    NSImage *image = [self.imageView image];
    NSArray * shareItems = [NSArray arrayWithObjects:text, image, nil];
 
    NSSharingService *service = [NSSharingService sharingServiceNamed:NSSharingServiceNamePostOnTwitter];
    service.delegate = self;
    [service performWithItems:shareItems];
}
```

## Topics

### Creating a Sharing Service

[`init(named:)`](/documentation/AppKit/NSSharingService/init(named:))

Returns a sharing service instance representing the specified service name.

[`init(title:image:alternateImage:handler:)`](/documentation/AppKit/NSSharingService/init(title:image:alternateImage:handler:))

Creates a custom sharing service object.

[`NSSharingService.Name`](/documentation/AppKit/NSSharingService/Name)

Constants that describe the sharing services that macOS supports.

### Managing the Delegate

[`delegate`](/documentation/AppKit/NSSharingService/delegate)

Specifies the delegate of the sharing service.

[`NSSharingServiceDelegate`](/documentation/AppKit/NSSharingServiceDelegate)

A set of methods that you use to customize the position and animation of a share sheet, and to be notified whether the item is successfully shared.

### Querying Service Availability

[`sharingServices(forItems:)`](/documentation/AppKit/NSSharingService/sharingServices(forItems:))

Returns a list of sharing services which could share all the provided items together.

[`canPerform(withItems:)`](/documentation/AppKit/NSSharingService/canPerform(withItems:))

Returns whether the service can share all the specified items.

### Getting the Service’s Details

[`accountName`](/documentation/AppKit/NSSharingService/accountName)

The account name used for posting on Twitter or Sina Weibo.

[`alternateImage`](/documentation/AppKit/NSSharingService/alternateImage)

The alternate image representing the sharing service.

[`image`](/documentation/AppKit/NSSharingService/image)

The primary image representing the sharing service.

[`title`](/documentation/AppKit/NSSharingService/title)

The title of the sharing service.

### Configuring the Service

[`menuItemTitle`](/documentation/AppKit/NSSharingService/menuItemTitle)

The title of the service in the Share menu.

[`recipients`](/documentation/AppKit/NSSharingService/recipients)

An array containing the user handles of the desired recipients.

[`subject`](/documentation/AppKit/NSSharingService/subject)

The subject of the post.

### Sharing Items

[`perform(withItems:)`](/documentation/AppKit/NSSharingService/perform(withItems:))

Manually performs the service on the provided items.

### Providing CloudKit Share Options

[`NSSharingService.CloudKitOptions`](/documentation/AppKit/NSSharingService/CloudKitOptions)

Constants that describe how a participant can configure a CloudKit share.

### Getting the Shared Items

[`attachmentFileURLs`](/documentation/AppKit/NSSharingService/attachmentFileURLs)

An array of NSURL objects representing the files that were shared.

[`messageBody`](/documentation/AppKit/NSSharingService/messageBody)

The message body as a string.

[`permanentLink`](/documentation/AppKit/NSSharingService/permanentLink)

A permanent URL (permalink) that your app can use to access the post.



---

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)