---
title: completeFileProtection
framework: foundation
role: symbol
role_heading: Type Property
path: foundation/nsdata/writingoptions/completefileprotection
---

# completeFileProtection

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

## Declaration

```swift
static var completeFileProtection: NSData.WritingOptions { get }
```

## Discussion

Discussion In this case, the system stores the file in an encrypted format and your app may only read or write to the file while the device is unlocked. At all other times, any  attempts your app makes to read and write the file will fail.

## See Also

### Constants

- [atomic](foundation/nsdata/writingoptions/atomic.md)
- [withoutOverwriting](foundation/nsdata/writingoptions/withoutoverwriting.md)
- [noFileProtection](foundation/nsdata/writingoptions/nofileprotection.md)
- [completeFileProtectionUnlessOpen](foundation/nsdata/writingoptions/completefileprotectionunlessopen.md)
- [completeFileProtectionUntilFirstUserAuthentication](foundation/nsdata/writingoptions/completefileprotectionuntilfirstuserauthentication.md)
- [fileProtectionMask](foundation/nsdata/writingoptions/fileprotectionmask.md)
- [completeFileProtectionWhenUserInactive](foundation/nsdata/writingoptions/completefileprotectionwhenuserinactive.md)
