<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.8.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSKeyedArchiver/requiresSecureCoding",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSKeyedArchiver(py)requiresSecureCoding"
  },
  "title" : "requiresSecureCoding"
}
-->

# requiresSecureCoding

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

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

## Parameters

`flag`

<doc://com.apple.documentation/documentation/Swift/true> if the receiver requires [`NSSecureCoding`](/documentation/Foundation/NSSecureCoding); <doc://com.apple.documentation/documentation/Swift/false> if not.

## 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`](/documentation/Foundation/NSSecureCoding).

Note that the getter is on the superclass, [`NSCoder`](/documentation/Foundation/NSCoder). See [`NSCoder`](/documentation/Foundation/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.

---

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)