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

# encodeRootObject(_:)

An encoding method for subclasses to override to encode an interconnected group of objects, starting with the provided root object.

## Declaration

```swift
func encodeRootObject(_ rootObject: Any)
```

## Discussion

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

## See Also

### Related Documentation

- [encodeRootObject(_:)](foundation/nsarchiver/encoderootobject(_:).md)

### 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)
- [encodeByrefObject(_:)](foundation/nscoder/encodebyrefobject(_:).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)
