---
title: "replacementObject(for:)"
framework: objectivec
role: symbol
role_heading: Instance Method
path: "objectivec/nsobject-swift.class/replacementobject(for:)-8ih2x"
---

# replacementObject(for:)

Overridden by subclasses to substitute another object for itself during archiving.

## Declaration

```swift
func replacementObject(for archiver: NSArchiver) -> Any?
```

## Parameters

- `archiver`: The archiver creating an archive.

## Return Value

Return Value The object to substitute for the receiver during archiving.

## Discussion

Discussion This method is invoked by NSArchiver. NSObject’s implementation returns the object returned by replacementObject(for:).

## See Also

### Archiving

- [awakeAfter(using:)](objectivec/nsobject-swift.class/awakeafter(using:).md)
- [classForArchiver](objectivec/nsobject-swift.class/classforarchiver.md)
- [classForCoder](objectivec/nsobject-swift.class/classforcoder.md)
- [classForKeyedArchiver](objectivec/nsobject-swift.class/classforkeyedarchiver.md)
- [classFallbacksForKeyedArchiver()](objectivec/nsobject-swift.class/classfallbacksforkeyedarchiver().md)
- [classForKeyedUnarchiver()](objectivec/nsobject-swift.class/classforkeyedunarchiver().md)
- [replacementObject(for:)](objectivec/nsobject-swift.class/replacementobject(for:)-2l8ox.md)
- [replacementObject(for:)](objectivec/nsobject-swift.class/replacementobject(for:)-60vwc.md)
- [setVersion(_:)](objectivec/nsobject-swift.class/setversion(_:).md)
- [version()](objectivec/nsobject-swift.class/version().md)
