<!--
{
  "availability" : [
    "iOS: 2.0.0 - 12.0.0",
    "iPadOS: 2.0.0 - 12.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.2.0 - 10.14.0",
    "tvOS: 9.0.0 - 12.0.0",
    "visionOS: 1.0.0 - 1.0.0",
    "watchOS: 2.0.0 - 5.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSKeyedUnarchiver/unarchiveObject(with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSKeyedUnarchiver(cm)unarchiveObjectWithData:"
  },
  "title" : "unarchiveObject(with:)"
}
-->

# unarchiveObject(with:)

Decodes and returns the object graph previously encoded by `NSKeyedArchiver` and stored in a given `NSData` object.

```
class func unarchiveObject(with data: Data) -> Any?
```

## Parameters

`data`

An object graph previously encoded by `NSKeyedArchiver`.

## Return Value

The object graph previously encoded by `NSKeyedArchiver` and stored in `data`.

## Discussion

This method raises an [`invalidArgumentException`](/documentation/Foundation/NSExceptionName/invalidArgumentException) if `data` is not a valid archive.

---

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)