O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required