<!--
{
  "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/setValue(_:forPasteboardType:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIPasteboard(im)setValue:forPasteboardType:"
  },
  "title" : "setValue(_:forPasteboardType:)"
}
-->

# setValue(_:forPasteboardType:)

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

```
func setValue(_ value: Any, forPasteboardType pasteboardType: String)
```

## Parameters

`value`

The object to be written to the pasteboard.

`pasteboardType`

A string identifying the representation type of the pasteboard item. If the type is a UTI, it must be compatible with the class of `value`; otherwise, nothing is written to the pasteboard.

## Discussion

Use this method to put an object—such as an <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> object—on the pasteboard. (For images, you can also use the [`image`](/documentation/UIKit/UIPasteboard/image) or [`images`](/documentation/UIKit/UIPasteboard/images) properties; for all other data, such as raw binary data, use the [`setData(_:forPasteboardType:)`](/documentation/UIKit/UIPasteboard/setData(_:forPasteboardType:)) method.) This method writes the object as the first item in the pasteboard. Calling this method replaces any items currently in the pasteboard.

---

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)