---
title: "unarchiveObject(withFile:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nsunarchiver/unarchiveobject(withfile:)"
---

# unarchiveObject(withFile:)

Decodes and returns the object archived in the file path.

## Declaration

```swift
class func unarchiveObject(withFile path: String) -> Any?
```

## Parameters

- `path`: The path to a file than contains an archive created using doc://com.apple.foundation/documentation/Foundation/NSArchiver.

## Return Value

Return Value The object, or object graph, that was archived in the file at path. Returns nil if the file at path cannot be unarchived.

## Discussion

Discussion This convenience method reads the file by invoking the NSData method dataWithContentsOfFile: and then invokes unarchiveObject(with:).

## See Also

### Decoding objects

- [unarchiveObject(with:)](foundation/nsunarchiver/unarchiveobject(with:).md)
