<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSData/WritingOptions",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@E@NSDataWritingOptions"
  },
  "title" : "NSData.WritingOptions"
}
-->

# NSData.WritingOptions

Options for methods used to write data objects.

```
struct WritingOptions
```

## Topics

### Initializers

[`init(rawValue:)`](/documentation/Foundation/NSData/WritingOptions/init(rawValue:))

### Constants

[`atomic`](/documentation/Foundation/NSData/WritingOptions/atomic)

An option to write data to an auxiliary file first and then replace the original file with the auxiliary file when the write completes.

[`withoutOverwriting`](/documentation/Foundation/NSData/WritingOptions/withoutOverwriting)

An option that attempts to write data to a file and fails with an error if the destination file already exists.

[`noFileProtection`](/documentation/Foundation/NSData/WritingOptions/noFileProtection)

An option to not encrypt the file when writing it out.

[`completeFileProtection`](/documentation/Foundation/NSData/WritingOptions/completeFileProtection)

An option to make the file accessible only while the device is unlocked.

[`completeFileProtectionUnlessOpen`](/documentation/Foundation/NSData/WritingOptions/completeFileProtectionUnlessOpen)

An option to allow the file to be accessible while the device is unlocked or the file is already open.

[`completeFileProtectionUntilFirstUserAuthentication`](/documentation/Foundation/NSData/WritingOptions/completeFileProtectionUntilFirstUserAuthentication)

An option to allow the file to be accessible after a user first unlocks the device.

[`fileProtectionMask`](/documentation/Foundation/NSData/WritingOptions/fileProtectionMask)

An option the system uses when determining the file protection options that the system assigns to the data.

[`completeFileProtectionWhenUserInactive`](/documentation/Foundation/NSData/WritingOptions/completeFileProtectionWhenUserInactive)

An option to allow the file to be accessible after a user first unlocks the device.

### Legacy Constants

[`atomicWrite`](/documentation/Foundation/NSData/WritingOptions/atomicWrite)

An option that attempts to write data to an auxiliary file first and then exchange the files.

[`atomicWrite`](/documentation/Foundation/NSData/WritingOptions/atomicWrite)

An option that attempts to write data to an auxiliary file first and then exchange the files.

### Entitlements

  <doc://com.apple.documentation/documentation/BundleResources/Entitlements/com.apple.developer.default-data-protection>



---

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)