<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSAttributedString/prefersRTFD(in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAttributedString(im)prefersRTFDInRange:"
  },
  "title" : "prefersRTFD(in:)"
}
-->

# prefersRTFD(in:)

Returns a Boolean value that indicates whether the specified range of text prefers RTFD formatting.

```
func prefersRTFD(in range: NSRange) -> Bool
```

## Parameters

`range`

The range of text to test.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the range of text prefers RTFD formatting, or <doc://com.apple.documentation/documentation/Swift/false> if you can use the RTF format instead.

## Discussion

When an attributed string contains attachments, you must save it using the RTFD file format to preserve the attached files.

---

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)