<!--
{
  "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/NSKeyedUnarchiver/requiresSecureCoding",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSKeyedUnarchiver(py)requiresSecureCoding"
  },
  "title" : "requiresSecureCoding"
}
-->

# requiresSecureCoding

Indicates whether the receiver requires all unarchived classes to conform to [`NSSecureCoding`](/documentation/Foundation/NSSecureCoding).

```
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 receiver to require secure coding, it will throw an exception if you attempt to unarchive a class which does not conform to [`NSSecureCoding`](/documentation/Foundation/NSSecureCoding).

The secure coding requirement for [`NSKeyedUnarchiver`](/documentation/Foundation/NSKeyedUnarchiver) is designed to be set once at the top level and remain on. Once enabled, attempting to call `setRequiresSecureCoding:` with a value of <doc://com.apple.documentation/documentation/Swift/false> will throw an exception. This is to prevent classes from selectively turning secure coding off.

Note that the getter is on the superclass, [`NSCoder`](/documentation/Foundation/NSCoder). See [`NSCoder`](/documentation/Foundation/NSCoder) for more information about secure coding.

---

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)