# Is the Encodable/Decodable system safe for asynchronous NSDocument handling?

**URL:** <https://forums.swift.org/t/is-the-encodable-decodable-system-safe-for-asynchronous-nsdocument-handling/34816>\
**Category:** Using Swift\
**Tags:** codable, asynchronous, appkit\
**Created:** [March 26, 2020, 7:38am UTC](https://forums.swift.org/t/is-the-encodable-decodable-system-safe-for-asynchronous-nsdocument-handling/34816 "2020-03-26T07:38:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CTMacUser](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ctmacuser/32/1802_2.png) [@CTMacUser](https://forums.swift.org/u/CTMacUser)\
**Post date:** [March 26, 2020, 7:38am UTC](https://forums.swift.org/t/is-the-encodable-decodable-system-safe-for-asynchronous-nsdocument-handling/34816/1 "2020-03-26T07:38:05Z")

</div>

I was just reading up on AppKit again and saw that the NSDocument system allows asynchronous loading and saving. If I use a `Codable` type for my model data, is the data translation safe to use in the background? How much does it depend on the model type’s code and the en/de-coder used? Do any of the default coders have hidden shared state that prevents this?

---

<div class="post-metadata">

**Author:** ![Lantua](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lantua/32/8868_2.png) [@Lantua](https://forums.swift.org/u/Lantua)\
**Post date:** [March 26, 2020, 1:59pm UTC](https://forums.swift.org/t/is-the-encodable-decodable-system-safe-for-asynchronous-nsdocument-handling/34816/2 "2020-03-26T13:59:37Z")

</div>

IIRC, the coding process itself doesn't mutate the top-level coders, so you can probably share them just fine. I'd go extra mile to create a separate coder, just to be sure.
