---
title: "init(forReadingWith:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nskeyedunarchiver/init(forreadingwith:)"
---

# init(forReadingWith:)

Initializes an archiver to decode data from the specified location.

## Declaration

```swift
init(forReadingWith data: Data)
```

## Parameters

- `data`: An archive previously encoded by doc://com.apple.foundation/documentation/Foundation/NSKeyedArchiver.

## Return Value

Return Value An NSKeyedUnarchiver object initialized for for decoding data.

## Discussion

Discussion When you finish decoding data, you should invoke finishDecoding(). This method throws an exception if data is not a valid archive.

## See Also

### Related Documentation

- [Archives and Serializations Programming Guide](apple-archive/documentation/Cocoa/Conceptual/Archiving.md)

### Creating a Keyed Unarchiver

- [init(forReadingFrom:)](foundation/nskeyedunarchiver/init(forreadingfrom:).md)
- [init()](foundation/nskeyedunarchiver/init().md)
