---
title: "archiver(_:didEncode:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nskeyedarchiverdelegate/archiver(_:didencode:)"
---

# archiver(_:didEncode:)

Informs the delegate that a given object has been encoded.

## Declaration

```swift
optional func archiver(_ archiver: NSKeyedArchiver, didEncode object: Any?)
```

## Parameters

- `archiver`: The archiver that sent the message.
- `object`: The object that has been encoded. object may be nil.

## Discussion

Discussion The delegate might restore some state it had modified previously, or use this opportunity to keep track of the objects that are encoded. This method is not called for conditional objects until they are actually encoded (if ever).

## See Also

### Related Documentation

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

### Encoding Data and Objects

- [archiverDidFinish(_:)](foundation/nskeyedarchiverdelegate/archiverdidfinish(_:).md)
- [archiver(_:willEncode:)](foundation/nskeyedarchiverdelegate/archiver(_:willencode:).md)
- [archiverWillFinish(_:)](foundation/nskeyedarchiverdelegate/archiverwillfinish(_:).md)
- [archiver(_:willReplace:with:)](foundation/nskeyedarchiverdelegate/archiver(_:willreplace:with:).md)
