---
title: "archivedData(withRootObject:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nskeyedarchiver/archiveddata(withrootobject:)"
---

# archivedData(withRootObject:)

Returns a data object that contains the encoded form of the object graph formed by the given root object.

## Declaration

```swift
class func archivedData(withRootObject rootObject: Any) -> Data
```

## Parameters

- `rootObject`: The root of the object graph to archive.

## Return Value

Return Value An NSData object containing the encoded form of the object graph whose root object is rootObject. The format of the archive is PropertyListSerialization.PropertyListFormat.binary.

## See Also

### Archiving Data

- [archivedData(withRootObject:requiringSecureCoding:)](foundation/nskeyedarchiver/archiveddata(withrootobject:requiringsecurecoding:).md)
- [finishEncoding()](foundation/nskeyedarchiver/finishencoding().md)
- [encodedData](foundation/nskeyedarchiver/encodeddata.md)
- [outputFormat](foundation/nskeyedarchiver/outputformat.md)
- [requiresSecureCoding](foundation/nskeyedarchiver/requiressecurecoding.md)
- [archiveRootObject(_:toFile:)](foundation/nskeyedarchiver/archiverootobject(_:tofile:).md)
