---
title: NSSharingService
framework: appkit
role: symbol
role_heading: Class
path: appkit/nssharingservice
---

# NSSharingService

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

## Declaration

```swift
class NSSharingService
```

## Overview

Overview An NSSharingService object provides a consistent user experience for sharing items—NSURL objects, NSString objects, NSImage objects, video (through file URLs), of any object that implements the NSPasteboardWriting protocol—in macOS. For any item or group of items, the 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 objects directly in your app. The following example shows how to create a button that shares content directly to a social media service. - (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:)](appkit/nssharingservice/init(named:).md)
- [init(title:image:alternateImage:handler:)](appkit/nssharingservice/init(title:image:alternateimage:handler:).md)
- [NSSharingService.Name](appkit/nssharingservice/name.md)

### Managing the Delegate

- [delegate](appkit/nssharingservice/delegate.md)
- [NSSharingServiceDelegate](appkit/nssharingservicedelegate.md)

### Querying Service Availability

- [sharingServices(forItems:)](appkit/nssharingservice/sharingservices(foritems:).md)
- [canPerform(withItems:)](appkit/nssharingservice/canperform(withitems:).md)

### Getting the Service’s Details

- [accountName](appkit/nssharingservice/accountname.md)
- [alternateImage](appkit/nssharingservice/alternateimage.md)
- [image](appkit/nssharingservice/image.md)
- [title](appkit/nssharingservice/title.md)

### Configuring the Service

- [menuItemTitle](appkit/nssharingservice/menuitemtitle.md)
- [recipients](appkit/nssharingservice/recipients.md)
- [subject](appkit/nssharingservice/subject.md)

### Sharing Items

- [perform(withItems:)](appkit/nssharingservice/perform(withitems:).md)

### Providing CloudKit Share Options

- [NSSharingService.CloudKitOptions](appkit/nssharingservice/cloudkitoptions.md)

### Getting the Shared Items

- [attachmentFileURLs](appkit/nssharingservice/attachmentfileurls.md)
- [messageBody](appkit/nssharingservice/messagebody.md)
- [permanentLink](appkit/nssharingservice/permanentlink.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### App Services

- [NSSharingServicePicker](appkit/nssharingservicepicker.md)
- [NSPreviewRepresentableActivityItem](appkit/nspreviewrepresentableactivityitem.md)
- [NSSharingServicePickerToolbarItem](appkit/nssharingservicepickertoolbaritem.md)
- [NSServicesMenuRequestor](appkit/nsservicesmenurequestor.md)
- [NSCloudSharingServiceDelegate](appkit/nscloudsharingservicedelegate.md)
- [Services Functions](appkit/services-functions.md)
