---
title: "encodeClassName(_:intoClassName:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsarchiver/encodeclassname(_:intoclassname:)"
---

# encodeClassName(_:intoClassName:)

Encodes a substitute name for the class with a given true name.

## Declaration

```swift
func encodeClassName(_ trueName: String, intoClassName inArchiveName: String)
```

## Parameters

- `trueName`: The real name of a class in the object graph being archived.
- `inArchiveName`: The name of the class to use in the archive in place of trueName.

## Discussion

Discussion Any subsequently encountered objects of class trueName are archived as instances of class inArchiveName. It is safest not to invoke this method during the archiving process (that is, within an encode(with:) method). Instead, invoke it before encodeRootObject(_:).

## See Also

### Substituting classes or objects

- [classNameEncoded(forTrueClassName:)](foundation/nsarchiver/classnameencoded(fortrueclassname:).md)
- [replace(_:with:)](foundation/nsarchiver/replace(_:with:).md)
