---
title: requiresSecureCoding
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/nskeyedarchiver/requiressecurecoding
---

# requiresSecureCoding

Indicates whether the archiver requires all archived classes to resist object substitution attacks.

## Declaration

```swift
var requiresSecureCoding: Bool { get set }
```

## Parameters

- `flag`: doc://com.apple.documentation/documentation/Swift/true if the receiver requires doc://com.apple.foundation/documentation/Foundation/NSSecureCoding; doc://com.apple.documentation/documentation/Swift/false if not.

## Discussion

Discussion If you set the archiver to require secure coding, it throws an exception if you attempt to archive a class which doesn’t conform to NSSecureCoding. Note that the getter is on the superclass, NSCoder. See NSCoder for more information about secure coding. note: Enabling secure coding doesn’t change the output format of the archive. This means that you can encode archives with secure coding enabled, and decode them later with secure coding disabled.

## See Also

### Archiving Data

- [archivedData(withRootObject:requiringSecureCoding:)](foundation/nskeyedarchiver/archiveddata(withrootobject:requiringsecurecoding:).md)
- [finishEncoding()](foundation/nskeyedarchiver/finishencoding().md)
- [encodedData](foundation/nskeyedarchiver/encodeddata.md)
- [outputFormat](foundation/nskeyedarchiver/outputformat.md)
- [archivedData(withRootObject:)](foundation/nskeyedarchiver/archiveddata(withrootobject:).md)
- [archiveRootObject(_:toFile:)](foundation/nskeyedarchiver/archiverootobject(_:tofile:).md)
