<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSText/rtfd(from:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSText(im)RTFDFromRange:"
  },
  "title" : "rtfd(from:)"
}
-->

# rtfd(from:)

Returns an NSData object that contains an RTFD stream corresponding to the characters and attributes within `aRange`.

```
func rtfd(from range: NSRange) -> Data?
```

## Discussion

Raises an `NSRangeException` if any part of `aRange` lies beyond the end of the receiver’s characters.

When writing data to the pasteboard, you can use the NSData object as the first argument to `NSPasteboard`’s [`setData(_:forType:)`](/documentation/AppKit/NSPasteboard/setData(_:forType:)) method, with a second argument of `NSRTFDPboardType`.

---

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)