<!--
{
  "availability" : [
    "iOS: 2.0.0 - 11.0.0",
    "iPadOS: 2.0.0 - 11.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.0.0 - 10.13.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSUnarchiver/init(forReadingWith:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSUnarchiver(im)initForReadingWithData:"
  },
  "title" : "init(forReadingWith:)"
}
-->

# init(forReadingWith:)

Returns an `NSUnarchiver` object initialized to read an archive from a given data object.

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

## Parameters

`data`

The archive data.

## Return Value

An `NSUnarchiver` object initialized to read an archive from `data`. Returns `nil` if `data` is not a valid archive.

## Discussion

The method decodes the system version number that was archived in `data` prepares the `NSUnarchiver` object for a subsequent invocation of [`decodeObject()`](/documentation/Foundation/NSCoder/decodeObject()).

Raises an `NSInvalidArgumentException` if `data` is `nil`.

## See Also

  [Archives and Serializations Programming Guide](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Archiving/Archiving.html#//apple_ref/doc/uid/10000047i)

[`systemVersion`](/documentation/Foundation/NSUnarchiver/systemVersion-swift.property)

The system version number in effect when the archive was created.



---

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)