---
title: "writeRTFD(toFile:atomically:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstext/writertfd(tofile:atomically:)"
---

# writeRTFD(toFile:atomically:)

Writes the receiver’s text as RTF with attachments to a file or directory at path.

## Declaration

```swift
func writeRTFD(toFile path: String, atomically flag: Bool) -> Bool
```

## Discussion

Discussion Returns true on success and false on failure. If atomicFlag is true, attempts to write the file safely so that an existing file at path is not overwritten, nor does a new file at path actually get created, unless the write is successful.

## See Also

### Reading and writing RTF files

- [readRTFD(fromFile:)](appkit/nstext/readrtfd(fromfile:).md)
- [rtfd(from:)](appkit/nstext/rtfd(from:).md)
- [rtf(from:)](appkit/nstext/rtf(from:).md)
