<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIPasteboard",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIPasteboard"
  },
  "title" : "UIPasteboard"
}
-->

# UIPasteboard

An object that helps a user share data from one place to another within your app, and from your app to other apps.

```
class UIPasteboard
```

## Overview

For sharing data with any other app, use the systemwide general pasteboard. For sharing data with another app from your team — that has the same team ID as the app to share from — configure an App Group. For more information about configuring an App Group, see <doc://com.apple.documentation/documentation/Xcode/configuring-app-groups>.

In typical usage, an object in your app writes data to a pasteboard when the user requests a copy, cut, or duplicate operation on a selection in the user interface. Another object in the same or different app then reads that data from the pasteboard and presents it to the user at a new location. This usually happens when the user requests a paste operation.

> Important:
> Starting in iOS 14, the system notifies the user when an app gets general pasteboard content that originates in a different app without *user intent*. The system determines user intent based on user interactions, such as tapping a system-provided control or pressing Command-V. Use the properties and methods below to determine whether pasteboard items match various patterns, such as web search terms, URLs, or numbers, without notifying the user.

### The general pasteboard and named pasteboards

The system identifies the systemwide general pasteboard with the [`general`](/documentation/UIKit/UIPasteboard/Name-swift.struct/general) pasteboard name, and you can use it for any type of data. Obtain the general pasteboard from the [`general`](/documentation/UIKit/UIPasteboard/general) shared system pasteboard object.

You can create named pasteboards with the class methods [`init(name:create:)`](/documentation/UIKit/UIPasteboard/init(name:create:)) and [`withUniqueName()`](/documentation/UIKit/UIPasteboard/withUniqueName()) for sharing data within your app, and from your app to other apps that have the same Team ID.

### Using pasteboards

The [`UIPasteboard`](/documentation/UIKit/UIPasteboard) class provides methods for reading and writing individual pasteboard items, as well as methods for reading and writing multiple pasteboard items at once. For more information, see [`Getting and setting pasteboard items`](/documentation/UIKit/UIPasteboard#Getting-and-setting-pasteboard-items) in the topic groups below. The data to write to a pasteboard can be in one of the following forms:

- If the data is an object that conforms to <doc://com.apple.documentation/documentation/Foundation/NSItemProviderWriting>, use [`setItemProviders(_:localOnly:expirationDate:)`](/documentation/UIKit/UIPasteboard/setItemProviders(_:localOnly:expirationDate:)) to write it to the pasteboard.
- If you can represent the data with a common object — such as <doc://com.apple.documentation/documentation/Foundation/NSString>, <doc://com.apple.documentation/documentation/Foundation/NSArray>, <doc://com.apple.documentation/documentation/Foundation/NSDictionary>, <doc://com.apple.documentation/documentation/Foundation/NSDate>, <doc://com.apple.documentation/documentation/Foundation/NSNumber>, [`UIImage`](/documentation/UIKit/UIImage), or <doc://com.apple.documentation/documentation/Foundation/NSURL> — you can write it to the pasteboard as a value using a method such as [`setValue(_:forPasteboardType:)`](/documentation/UIKit/UIPasteboard/setValue(_:forPasteboardType:)).
- If the data is binary, use the [`setData(_:forPasteboardType:)`](/documentation/UIKit/UIPasteboard/setData(_:forPasteboardType:)) method to write it to the pasteboard.

The [`UIPasteboard`](/documentation/UIKit/UIPasteboard) class provides convenience methods for writing and reading strings, images, URLs, and colors to and from single or multiple pasteboard items. See [`Getting and setting pasteboard items of standard data types`](/documentation/UIKit/UIPasteboard#Getting-and-setting-pasteboard-items-of-standard-data-types) in the topic groups below.

> Note:
> Before you attempt to read a particular data type from a pasteboard by using the methods in <doc://com.apple.uikit/documentation/UIKit/UIPasteboard#Getting-and-setting-pasteboard-items-of-standard-data-types> in the topic groups below, check for the presence of data of the type you want. Do this by using the type-checking methods.

[`UIPasteboard`](/documentation/UIKit/UIPasteboard) provides properties for directly checking whether specific data types are present on a pasteboard, see [`Checking for data types on a pasteboard`](/documentation/UIKit/UIPasteboard#Checking-for-data-types-on-a-pasteboard) in the topic groups below. Use these properties, rather than attempting to read pasteboard data, to avoid causing the system to needlessly attempt to fetch data before necessary, or when the data might not be present. For example, use the [`hasStrings`](/documentation/UIKit/UIPasteboard/hasStrings) property to determine whether to present a string-data paste option in the user interface, using code like the following:

```objc
if UIPasteboard.general.hasStrings {
    // Enable string-related control...
}
```

Use the following properties to avoid user notifications and alerts when the system doesn’t establish user intent:

- [`numberOfItems`](/documentation/UIKit/UIPasteboard/numberOfItems)
- [`types`](/documentation/UIKit/UIPasteboard/types), [`types(forItemSet:)`](/documentation/UIKit/UIPasteboard/types(forItemSet:))
- [`itemSet(withPasteboardTypes:)`](/documentation/UIKit/UIPasteboard/itemSet(withPasteboardTypes:))
- [`hasColors`](/documentation/UIKit/UIPasteboard/hasColors), [`hasImages`](/documentation/UIKit/UIPasteboard/hasImages), [`hasStrings`](/documentation/UIKit/UIPasteboard/hasStrings), [`hasURLs`](/documentation/UIKit/UIPasteboard/hasURLs)
- <doc://com.apple.documentation/documentation/Foundation/NSItemProvider/canLoadObject(ofClass:)-3eig9>, <doc://com.apple.documentation/documentation/Foundation/NSItemProvider/canLoadObject(ofClass:)-40grc>
- any of the pattern-detection methods in the [`Detecting patterns of content in pasteboard items`](/documentation/UIKit/UIPasteboard#Detecting-patterns-of-content-in-pasteboard-items) group in the topic groups below

The system notifies the user when you access properties or call methods that pull data from the pasteboard if the system doesn’t determine that the user intends to access that data.

### Pasteboard items and representation types

When you write an object to a pasteboard, the pasteboard stores it as a *pasteboard item*. A pasteboard item consists of one or more key-value pairs in which the key identifies the representation type (sometimes called a *pasteboard type*) of the value.

A uniform type identifier frequently functions as the key for a representation type. For example, you can use the <doc://com.apple.documentation/documentation/UniformTypeIdentifiers/UTTypeJPEG> uniform type identifier (a constant for `public.jpeg`) as a representation type key for JPEG data.

For a discussion of uniform type identifiers, and a list of common ones, see <doc://com.apple.documentation/documentation/UniformTypeIdentifiers>.

Your app can use any string to name a representation type; however, for app-specific data types, it’s best practice to use reverse-DNS notation to ensure the uniqueness of the type (for example, `com.myCompany.myApp.myType`).

You can provide flexibility for data sharing by providing multiple representation types for a pasteboard item during a copy or cut operation. Various contexts within your app or other apps can then make use of an appropriate representation type. For example, when a user copies an image, your app can write multiple representation types, such as in the PNG, JPEG, and GIF data formats, to a pasteboard. If the original image is in PNG format, but the receiving app can handle only GIF images, it can still use the pasteboard data.

For more about representation types, read the discussion for the [`types`](/documentation/UIKit/UIPasteboard/types) instance method.

### Sharing pasteboards between devices

When a user signs into iCloud, the general pasteboard automatically transfers its contents to nearby devices that use the same iCloud account. You can control Handoff behavior when writing contents to the general pasteboard, and can set an expiration for items, using the [`setItemProviders(_:localOnly:expirationDate:)`](/documentation/UIKit/UIPasteboard/setItemProviders(_:localOnly:expirationDate:)), [`setObjects(_:localOnly:expirationDate:)`](/documentation/UIKit/UIPasteboard/setObjects(_:localOnly:expirationDate:)-3h3iz), or [`setItems(_:options:)`](/documentation/UIKit/UIPasteboard/setItems(_:options:)) methods, as follows:

- To exclude a pasteboard from Handoff, specify <doc://com.apple.documentation/documentation/Swift/false> for the `localOnly` parameter, or call the [`setItems(_:options:)`](/documentation/UIKit/UIPasteboard/setItems(_:options:)) method with the [`localOnly`](/documentation/UIKit/UIPasteboard/OptionsKey/localOnly) option.
- To indicate an expiration time and date for copied data, provide the `expirationDate` parameter, or call the [`setItems(_:options:)`](/documentation/UIKit/UIPasteboard/setItems(_:options:)) method with the [`expirationDate`](/documentation/UIKit/UIPasteboard/OptionsKey/expirationDate) option. At the time and date that you set, the system removes the pasteboard items from the pasteboard.

### Using pasteboards with other objects

Although the [`UIPasteboard`](/documentation/UIKit/UIPasteboard) class is central to copy, paste, and duplicate operations, you can employ protocols and instances of other UIKit classes in these operations as well, such as the following:

- [`UIEditMenuInteraction`](/documentation/UIKit/UIEditMenuInteraction) — Displays a menu with edit actions, such as Copy, Cut, Paste, Select, and Select All, above or below the selection.
- [`UIActivityItemsConfigurationReading`](/documentation/UIKit/UIActivityItemsConfigurationReading) — Objects implement this protocol to indicate that they support copying and sharing data.
- [`UIPasteConfigurationSupporting`](/documentation/UIKit/UIPasteConfigurationSupporting) — Objects implement this protocol to indicate whether they support pasting with a specific [`UIPasteConfiguration`](/documentation/UIKit/UIPasteConfiguration).
- [`UIResponder`](/documentation/UIKit/UIResponder) — Responders implement [`canPerformAction(_:withSender:)`](/documentation/UIKit/UIResponder/canPerformAction(_:withSender:)) to enable or disable commands in the above-mentioned menu based on the current context.
- [`UIResponderStandardEditActions`](/documentation/UIKit/UIResponderStandardEditActions) — Responders implement methods that this informal protocol declares to handle the chosen menu commands (for example, `copy:` and `paste:`).

A typical app that implements copy, paste, and duplicate operations also manages and presents related selections in its user interface. In addition, your app needs to coordinate changes in pasteboard content with changes to its data model, as appropriate for your app.

## Topics

### Getting and removing pasteboards

[`general`](/documentation/UIKit/UIPasteboard/general)

The systemwide general pasteboard, which you use for general copy-paste operations.

[`init(name:create:)`](/documentation/UIKit/UIPasteboard/init(name:create:))

Returns a pasteboard that you identify by name, optionally creating it if it doesn’t exist.

[`withUniqueName()`](/documentation/UIKit/UIPasteboard/withUniqueName())

Returns an app pasteboard that you identify by a unique system-generated name.

[`remove(withName:)`](/documentation/UIKit/UIPasteboard/remove(withName:))

Invalidates the designated app pasteboard.

### Getting and setting pasteboard attributes

[`name`](/documentation/UIKit/UIPasteboard/name-swift.property)

The name of the pasteboard.

[`changeCount`](/documentation/UIKit/UIPasteboard/changeCount)

The number of times the pasteboard’s contents change.

### Detecting patterns of content in pasteboard items

[`detectPatterns(for:completionHandler:)`](/documentation/UIKit/UIPasteboard/detectPatterns(for:completionHandler:)-23vwn)

Requests that the data detection system identify the patterns that you specify for the pasteboard, and provide the patterns that it matches to your closure.

[`detectedPatterns(for:)`](/documentation/UIKit/UIPasteboard/detectedPatterns(for:))

Requests that the data detection system asynchronously identify the patterns that you specify for the pasteboard, and return the patterns that it matches.

[`detectPatterns(for:inItemSet:completionHandler:)`](/documentation/UIKit/UIPasteboard/detectPatterns(for:inItemSet:completionHandler:)-7ubl1)

Requests that the data detection system identify the patterns that you specify for the pasteboard items, and provide the patterns that it matches to your closure.

[`detectedPatterns(for:inItemSet:)`](/documentation/UIKit/UIPasteboard/detectedPatterns(for:inItemSet:))

Requests that the data detection system asynchronously identify the patterns that you specify for the pasteboard items, and return the patterns that it matches.

[`detectValues(for:completionHandler:)`](/documentation/UIKit/UIPasteboard/detectValues(for:completionHandler:)-6adre)

Requests that the data detection system identify the types of data that you specify for the pasteboard, and provide the values that it matches to your closure.

[`detectedValues(for:)`](/documentation/UIKit/UIPasteboard/detectedValues(for:))

Requests that the data detection system asynchronously identify the types of values that you specify for the pasteboard, and return the values that it matches.

[`detectValues(for:inItemSet:completionHandler:)`](/documentation/UIKit/UIPasteboard/detectValues(for:inItemSet:completionHandler:)-pm9l)

Requests that the data detection system identify the types of data that you specify for the pasteboard items, and provide the values that it matches to your closure.

[`detectedValues(for:inItemSet:)`](/documentation/UIKit/UIPasteboard/detectedValues(for:inItemSet:))

Requests that the data detection system asynchronously identify the types of values that you specify for the pasteboard item, and return the values that it matches for each pasteboard.

[`UIPasteboard.DetectedValues`](/documentation/UIKit/UIPasteboard/DetectedValues)

An object that contains common types of data that the data detection system matches for a pasteboard.

[`detectPatternsForPatterns:completionHandler:`](/documentation/UIKit/UIPasteboard/detectPatternsForPatterns:completionHandler:)

Determines whether the first pasteboard item matches the specified patterns, without notifying the user.

[`detectPatternsForPatterns:inItemSet:completionHandler:`](/documentation/UIKit/UIPasteboard/detectPatternsForPatterns:inItemSet:completionHandler:)

Determines whether pasteboard items match the specified patterns, without notifying the user.

[`detectValuesForPatterns:completionHandler:`](/documentation/UIKit/UIPasteboard/detectValuesForPatterns:completionHandler:)

Determines whether the first pasteboard item matches the specified patterns, reading the contents if it finds a match.

[`detectValuesForPatterns:inItemSet:completionHandler:`](/documentation/UIKit/UIPasteboard/detectValuesForPatterns:inItemSet:completionHandler:)

Determines whether pasteboard items match the specified patterns, reading the contents if it finds a match.

[`UIPasteboard.DetectionPattern`](/documentation/UIKit/UIPasteboard/DetectionPattern)

An object that represents a pattern to detect for the pasteboard, such as a URL, text, or a number.

### Determining types of pasteboard items

[`types`](/documentation/UIKit/UIPasteboard/types)

The types of the first item on the pasteboard.

[`types(forItemSet:)`](/documentation/UIKit/UIPasteboard/types(forItemSet:))

Returns an array of representation types for each specified pasteboard item.

[`contains(pasteboardTypes:)`](/documentation/UIKit/UIPasteboard/contains(pasteboardTypes:))

Returns whether the pasteboard holds data of the specified representation type.

[`contains(pasteboardTypes:inItemSet:)`](/documentation/UIKit/UIPasteboard/contains(pasteboardTypes:inItemSet:))

Returns whether the specified pasteboard items contain data of the given representation types.

[`itemSet(withPasteboardTypes:)`](/documentation/UIKit/UIPasteboard/itemSet(withPasteboardTypes:))

Returns an index set identifying pasteboard items having the specified representation types.

### Getting and setting pasteboard items

[`numberOfItems`](/documentation/UIKit/UIPasteboard/numberOfItems)

The number of items for the pasteboard.

[`items`](/documentation/UIKit/UIPasteboard/items)

The pasteboard items on the pasteboard.

[`addItems(_:)`](/documentation/UIKit/UIPasteboard/addItems(_:))

Appends pasteboard items to the current contents of the pasteboard.

[`setItems(_:options:)`](/documentation/UIKit/UIPasteboard/setItems(_:options:))

Adds an array of items to a pasteboard, and sets privacy options for all the items on the pasteboard.

[`data(forPasteboardType:)`](/documentation/UIKit/UIPasteboard/data(forPasteboardType:))

Returns the data on the pasteboard for the given representation type.

[`data(forPasteboardType:inItemSet:)`](/documentation/UIKit/UIPasteboard/data(forPasteboardType:inItemSet:))

Returns the data objects in the indicated pasteboard items that have the given representation type.

[`setData(_:forPasteboardType:)`](/documentation/UIKit/UIPasteboard/setData(_:forPasteboardType:))

Puts data on the pasteboard for the specified representation type.

[`value(forPasteboardType:)`](/documentation/UIKit/UIPasteboard/value(forPasteboardType:))

Returns an object on the pasteboard for the given representation type.

[`values(forPasteboardType:inItemSet:)`](/documentation/UIKit/UIPasteboard/values(forPasteboardType:inItemSet:))

Returns the objects on the indicated pasteboard items that have the given representation type.

[`setValue(_:forPasteboardType:)`](/documentation/UIKit/UIPasteboard/setValue(_:forPasteboardType:))

Puts an object on the pasteboard for the specified representation type.

### Getting and setting pasteboard items of standard data types

[`string`](/documentation/UIKit/UIPasteboard/string)

The string value of the first pasteboard item.

[`strings`](/documentation/UIKit/UIPasteboard/strings)

An array of strings in all pasteboard items.

[`image`](/documentation/UIKit/UIPasteboard/image)

The image object of the first pasteboard item.

[`images`](/documentation/UIKit/UIPasteboard/images)

An array of image objects in all pasteboard items.

[`url`](/documentation/UIKit/UIPasteboard/url)

The URL object of the first pasteboard item.

[`urls`](/documentation/UIKit/UIPasteboard/urls)

An array of URL objects in all pasteboard items.

[`color`](/documentation/UIKit/UIPasteboard/color)

The color object of the first pasteboard item.

[`colors`](/documentation/UIKit/UIPasteboard/colors)

An array of color objects in all pasteboard items.

### Checking for data types on a pasteboard

[`hasColors`](/documentation/UIKit/UIPasteboard/hasColors)

A Boolean value that indicates whether the pasteboard contains contains a nonempty array of colors.

[`hasImages`](/documentation/UIKit/UIPasteboard/hasImages)

A Boolean value that indicates whether the pasteboard contains a nonempty array of images.

[`hasStrings`](/documentation/UIKit/UIPasteboard/hasStrings)

A Boolean value that indicates whether the pasteboard contains a nonempty array of strings.

[`hasURLs`](/documentation/UIKit/UIPasteboard/hasURLs)

A Boolean value that indicates whether the pasteboard contains a nonempty array of URLs.

### Getting and setting item providers

[`itemProviders`](/documentation/UIKit/UIPasteboard/itemProviders)

An array of item providers for the pasteboard.

[`setItemProviders(_:localOnly:expirationDate:)`](/documentation/UIKit/UIPasteboard/setItemProviders(_:localOnly:expirationDate:))

Sets and configures an explicit array of item providers for the pasteboard.

[`setObjects(_:)`](/documentation/UIKit/UIPasteboard/setObjects(_:)-lljo)

Sets an array of item providers for the pasteboard, based on a specified array of objects.

[`setObjects(_:)`](/documentation/UIKit/UIPasteboard/setObjects(_:)-fjg8)

Sets an array of item providers for the pasteboard, based on a specified array of objects.

[`setObjects(_:localOnly:expirationDate:)`](/documentation/UIKit/UIPasteboard/setObjects(_:localOnly:expirationDate:)-3h3iz)

Sets and configures an array of item providers for the pasteboard, based on a specified array of objects.

[`setObjects(_:localOnly:expirationDate:)`](/documentation/UIKit/UIPasteboard/setObjects(_:localOnly:expirationDate:)-26u8o)

Sets and configures an array of item providers for the pasteboard, based on a specified array of objects.

### Constants

[`UIPasteboard.Name`](/documentation/UIKit/UIPasteboard/Name-swift.struct)

Constants that identify the name of a pasteboard.

[Pasteboard Names](/documentation/UIKit/pasteboard-names)

Names identifying the system pasteboards.

[`UIPasteboard.OptionsKey`](/documentation/UIKit/UIPasteboard/OptionsKey)

Options for describing pasteboard privacy.

[Pasteboard Data Type Representations](/documentation/UIKit/pasteboard-data-type-representations)

Pasteboard-item representation types, as for a given object value.

[UserInfo Dictionary Keys](/documentation/UIKit/userinfo-dictionary-keys)

Use these keys to access the representation types of pasteboard items that you add to, or remove from, a pasteboard.

### Notifications

[`changedNotification`](/documentation/UIKit/UIPasteboard/changedNotification)

A notification that a pasteboard object posts when its contents change.

[`removedNotification`](/documentation/UIKit/UIPasteboard/removedNotification)

A notification that a pasteboard object posts just before an app removes it.

### Deprecated

[Deprecated symbols](/documentation/UIKit/uipasteboard-deprecated-symbols)

Review unsupported symbols and their replacements.



---

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)