<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSKeyedArchiver/init(requiringSecureCoding:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSKeyedArchiver(im)initRequiringSecureCoding:"
  },
  "title" : "init(requiringSecureCoding:)"
}
-->

# init(requiringSecureCoding:)

Creates an archiver to encode data, and optionally disables secure coding.

```
init(requiringSecureCoding requiresSecureCoding: Bool)
```

## Parameters

`requiresSecureCoding`

A Boolean value indicating whether all encoded objects must conform to [`NSSecureCoding`](/documentation/Foundation/NSSecureCoding).

## Discussion

To prevent the possibility of encoding an object that [`NSKeyedUnarchiver`](/documentation/Foundation/NSKeyedUnarchiver) can’t decode, set `requiresSecureCoding` to <doc://com.apple.documentation/documentation/Swift/true> whenever possible. This ensures that all encoded objects conform to [`NSSecureCoding`](/documentation/Foundation/NSSecureCoding).

> 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

[`requiresSecureCoding`](/documentation/Foundation/NSKeyedArchiver/requiresSecureCoding)

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



---

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)