Swiftpack.co - Package - ChimeHQ/ContainedDocument

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.


Nested NSDocuments

Carthage compatible


ContainedDocument allows you to nest NSDocument instances inside of abstract containers. These can be anything you need, including other NSDocument instances. This turns out to be a very tricky thing to do, and requires careful management of an NSDocumentController to make it possible.



You can use Carthage to intall this as a static library.

github "ChimeHQ/ContainedDocument"

Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/ChimeHQ/ContainedDocument.git")



An NSDocumentController subclass that manages the NSDocument lifecycle and manages the relationship to your containers. It provides for potentially useful subclassing points if you need to further tweak the behavior.

open func associateDocument(_ document: NSDocument, to container: Container)
open func disassociateDocument(_ document: NSDocument)

open func encodeRestorableState(with coder: NSCoder, for document: NSDocument)
open func restoreState(with coder: NSCoder, for document: NSDocument)
// ...


This is an optional NSDocument subclass that allows for tighter window restoration integration between NSDocument and ContainedDocumentController. Restoring your container relationships could be challenging without this mechanism.

Suggestions or Feedback

We'd love to hear from you! Get in touch via twitter, an issue, or a pull request.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.


Stars: 3
Last commit: 2 weeks ago


v0.1 - 2021-02-16T17:28:24

Initial Release