---
title: "rtfd(from:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstext/rtfd(from:)"
---

# rtfd(from:)

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

## Declaration

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

## Discussion

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:) method, with a second argument of NSRTFDPboardType.

## See Also

### Reading and writing RTF files

- [readRTFD(fromFile:)](appkit/nstext/readrtfd(fromfile:).md)
- [writeRTFD(toFile:atomically:)](appkit/nstext/writertfd(tofile:atomically:).md)
- [rtf(from:)](appkit/nstext/rtf(from:).md)
