AWF4vk
AWF4vk

Reputation: 5890

Are NSDocument* classes only for document-based applications?

I'm wondering if NSDocument is only for applications that are text/document-based. I have an application that uses multiple windows, which together form a project. Would it be a good idea to implement those windows as NSDocuments?

Upvotes: 2

Views: 152

Answers (1)

Jonathan Grynspan
Jonathan Grynspan

Reputation: 43472

NSDocument models a document, but a document doesn't need to be text-based. Typically, it is the in-memory representation of a file on disk. If your application works with files in a particular format (e.g. images or text or code or genomes or graphs...) then NSDocument will typically be the correct class to use when modelling those files.

If, however, you have windows which don't model files, NSDocument is the wrong tool to use because it is geared toward file manipulation. Instead, you would typically use one NSWindowController per window (or per closely-related set of windows) to control your UI.

Upvotes: 2

Related Questions