Name

NSDocument — Mac OS X 10.0

Synopsis

This class is one of three that comprise Cocoa’s document-based application architecture; the other two are NSDocumentController and NSWindowController. NSDocument is an abstract class that defines the fundamental interface for objects that represent documents. This interface includes methods for loading and saving a document’s contents, managing a document’s windows, handling print jobs, and managing an undo manager. NSDocument is never used directly; rather, developers subclass NSDocument and implement the key methods to tailor the document to their needs.

image with no caption

@interface NSDocument : NSObject
                                  // Initializers
   - (id)init;
   - (id)initWithContentsOfFile:(NSString *)fileName 
                                 ofType:(NSString *)fileType;
   - (id)initWithContentsOfURL:(NSURL *)url 
                                 ofType:(NSString *)fileType;
                                  // Accessor Methods
   - (void)setHasUndoManager:(BOOL)flag;
   - (BOOL)hasUndoManager;
   - (void)setFileType:(NSString *)type;
   - (NSString *)fileType;
   - (void)setFileName:(NSString *)fileName;
   - (NSString *)fileName;
   - (void)setUndoManager:(NSUndoManager *)undoManager;
   - (NSUndoManager *)undoManager;
   - (void)setPrintInfo:(NSPrintInfo *)printInfo;
   - (NSPrintInfo *)printInfo;
   - (void)setWindow:(NSWindow *)window;
                                  // Class Methods
   + (BOOL)isNativeType:(NSString *)type;
   + (NSArray *)readableTypes;
   + (NSArray *)writableTypes;
                                  // Instance Methods ...

Get Cocoa in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.