<!--
{
  "availability" : [
    "macOS: 10.6.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSPasteboardItem/setString(_:forType:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPasteboardItem(im)setString:forType:"
  },
  "title" : "setString(_:forType:)"
}
-->

# setString(_:forType:)

Sets the value for a specified type as a string.

```
func setString(_ string: String, forType type: NSPasteboard.PasteboardType) -> Bool
```

## Parameters

`string`

A string for the representation specified by `type`.

`type`

A uniform type identifier string.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the value was set successfully, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

---

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)