---
title: "setData(_:forPasteboardType:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uipasteboard/setdata(_:forpasteboardtype:)"
---

# setData(_:forPasteboardType:)

Puts data on the pasteboard for the specified representation type.

## Declaration

```swift
func setData(_ data: Data, forPasteboardType pasteboardType: String)
```

## Parameters

- `data`: The data object to be written to the pasteboard.
- `pasteboardType`: A string identifying the representation type of the pasteboard item. This is typically a UTI.

## Discussion

Discussion Use this method to put raw data on the pasteboard. For example, you could archive a graph of model objects and pass the resulting NSData object to a related app via a pasteboard using a custom pasteboard type. (To put objects—such as NSString, NSArray, NSDictionary, NSDate, NSNumber, UIImage, or NSURL objects—on the pasteboard, use the setValue(_:forPasteboardType:) method.) This method writes data for the first item in the pasteboard. Calling this method replaces any items currently in the pasteboard.

## See Also

### Getting and setting pasteboard items

- [numberOfItems](uikit/uipasteboard/numberofitems.md)
- [items](uikit/uipasteboard/items.md)
- [addItems(_:)](uikit/uipasteboard/additems(_:).md)
- [setItems(_:options:)](uikit/uipasteboard/setitems(_:options:).md)
- [data(forPasteboardType:)](uikit/uipasteboard/data(forpasteboardtype:).md)
- [data(forPasteboardType:inItemSet:)](uikit/uipasteboard/data(forpasteboardtype:initemset:).md)
- [value(forPasteboardType:)](uikit/uipasteboard/value(forpasteboardtype:).md)
- [values(forPasteboardType:inItemSet:)](uikit/uipasteboard/values(forpasteboardtype:initemset:).md)
- [setValue(_:forPasteboardType:)](uikit/uipasteboard/setvalue(_:forpasteboardtype:).md)
