---
title: finishEncoding()
framework: foundation
role: symbol
role_heading: Instance Method
path: foundation/nskeyedarchiver/finishencoding()
---

# finishEncoding()

Instructs the receiver to construct the final data stream.

## Declaration

```swift
func finishEncoding()
```

## Discussion

Discussion No more values can be encoded after this method is called. You must call this method when finished.

## See Also

### Related Documentation

- [init(forWritingWith:)](foundation/nskeyedarchiver/init(forwritingwith:).md)

### Archiving Data

- [archivedData(withRootObject:requiringSecureCoding:)](foundation/nskeyedarchiver/archiveddata(withrootobject:requiringsecurecoding:).md)
- [encodedData](foundation/nskeyedarchiver/encodeddata.md)
- [outputFormat](foundation/nskeyedarchiver/outputformat.md)
- [requiresSecureCoding](foundation/nskeyedarchiver/requiressecurecoding.md)
- [archivedData(withRootObject:)](foundation/nskeyedarchiver/archiveddata(withrootobject:).md)
- [archiveRootObject(_:toFile:)](foundation/nskeyedarchiver/archiverootobject(_:tofile:).md)
