---
title: "encodeByrefObject(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nscoder/encodebyrefobject(_:)"
---

# encodeByrefObject(_:)

An encoding method for subclasses to override such that it creates a proxy, rather than a copy, when decoded.

## Declaration

```swift
func encodeByrefObject(_ anObject: Any?)
```

## Discussion

Discussion NSCoder’s implementation simply invokes encode(_:). This method must be matched by a corresponding decodeObject() message.

## See Also

### Encoding General Data

- [encodeArray(ofObjCType:count:at:)](foundation/nscoder/encodearray(ofobjctype:count:at:).md)
- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-7o6mu.md)
- [encodeBycopyObject(_:)](foundation/nscoder/encodebycopyobject(_:).md)
- [encodeBytes(_:length:)](foundation/nscoder/encodebytes(_:length:).md)
- [encodeBytes(_:length:forKey:)](foundation/nscoder/encodebytes(_:length:forkey:).md)
- [encodeConditionalObject(_:)](foundation/nscoder/encodeconditionalobject(_:).md)
- [encodeConditionalObject(_:forKey:)](foundation/nscoder/encodeconditionalobject(_:forkey:).md)
- [encode(_:)](foundation/nscoder/encode(_:)-1qd1e.md)
- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-9xiiu.md)
- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-84cez.md)
- [encodeCInt(_:forKey:)](foundation/nscoder/encodecint(_:forkey:).md)
- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-2dprz.md)
- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-5sk4z.md)
- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-dixg.md)
- [encode(_:)](foundation/nscoder/encode(_:)-9648d.md)
