NSDocument object manages an application’s documents. As the first-responder target of New and Open menu commands, it creates and opens documents and tracks them throughout a session of the application. When opening documents, an
NSDocument runs and manages the modal Open panel.
NSDocument objects also maintain and manage the mappings of document types, extensions, and
NSDocument subclasses as specified in the
CFBundle property loaded from the information property list (
- macOS 10.0+
You can use various
NSDocument methods to get a list of the current documents, get the current document (which is the document whose window is currently key), get documents based on a given filename or window, and find out about a document’s extension, type, display name, and document class.
In some situations, it is worthwhile to subclass
NSDocument in non-
NSDocument-based applications to get some of its features. For example, the
NSDocument management of the Open Recent menu is useful in applications that don’t use subclasses of