---
title: "init(requiringSecureCoding:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nskeyedarchiver/init(requiringsecurecoding:)"
---

# init(requiringSecureCoding:)

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

## Declaration

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

## Parameters

- `requiresSecureCoding`: A Boolean value indicating whether all encoded objects must conform to doc://com.apple.foundation/documentation/Foundation/NSSecureCoding.

## Discussion

Discussion To prevent the possibility of encoding an object that NSKeyedUnarchiver can’t decode, set requiresSecureCoding to true whenever possible. This ensures that all encoded objects conform to 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

### Related Documentation

- [requiresSecureCoding](foundation/nskeyedarchiver/requiressecurecoding.md)

### Creating a Keyed Archiver

- [init()](foundation/nskeyedarchiver/init().md)
- [init(forWritingWith:)](foundation/nskeyedarchiver/init(forwritingwith:).md)
