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.
@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 |
- (NSData *)dataRepresentationOfType:(NSString *)type;
|
- (NSString *)displayName;
|
- (void)addWindowController:(NSWindowController *)windowController;
|
- (BOOL)canCloseDocument;
|
- (NSDictionary *)fileAttributesToWriteToFile:(NSString *)fullDocumentPath ofType:(NSString *)documentTypeName
saveOperation:(NSSaveOperationType)saveOperationType;
|
- (void)canCloseDocumentWithDelegate:(id)delegate shouldCloseSelector:(SEL)shouldCloseSelector
contextInfo:(void *)contextInfo;
|
- (void)close;
|
- (BOOL)fileNameExtensionWasHiddenInLastRunSavePanel;
|
- (NSString *)fileNameFromRunningSavePanelForSaveOperation:(NSSaveOperationType)saveOperation;
|
- (NSString *)fileTypeFromLastRunSavePanel;
|
- (NSFileWrapper *)fileWrapperRepresentationOfType:(NSString *)type;
|
- (BOOL)isDocumentEdited;
|
- (BOOL)keepBackupFile;
|
- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)type;
|
- (BOOL)loadFileWrapperRepresentation:(NSFileWrapper *)wrapper ofType:(NSString *)type;
|
- (void)makeWindowControllers;
|
- (BOOL)preparePageLayout:(NSPageLayout *)pageLayout;
|
- (BOOL)prepareSavePanel:(NSSavePanel *)savePanel;
|
- (IBAction)printDocument:(id)sender;
|
- (void)printShowingPrintPanel:(BOOL)flag;
|
- (BOOL)readFromFile:(NSString *)fileName ofType:(NSString *)type;
|
- (BOOL)readFromURL:(NSURL *)url ofType:(NSString *)type;
|
- (void)removeWindowController:(NSWindowController *)windowController;
|
- (IBAction)revertDocumentToSaved:(id)sender;
|
- (BOOL)revertToSavedFromFile:(NSString *)fileName ofType:(NSString *)type;
|
- (BOOL)revertToSavedFromURL:(NSURL *)url ofType:(NSString *)type;
|
- (int)runModalPageLayoutWithPrintInfo:(NSPrintInfo *)printInfo;
|
- (void)runModalPageLayoutWithPrintInfo:(NSPrintInfo *)printInfo
delegate:(id)delegate didRunSelector:(SEL)didRunSelector contextInfo:(void *)contextInfo;
|
- (void)runModalPrintOperation:(NSPrintOperation *)printOperation
delegate:(id)delegate didRunSelector:(SEL)didRunSelector contextInfo:(void *)contextInfo;
|
- (int)runModalSavePanel:(NSSavePanel *)savePanel withAccessoryView:(NSView *)accessoryView;
|
- (void)runModalSavePanelForSaveOperation:(NSSaveOperationType)saveOperation
delegate:(id)delegate didSaveSelector:(SEL)didSaveSelector contextInfo:(void *)contextInfo;
|
- (IBAction)runPageLayout:(id)sender;
|
- (IBAction)saveDocument:(id)sender;
|
- (IBAction)saveDocumentAs:(id)sender;
|
- (IBAction)saveDocumentTo:(id)sender;
|
- (void)saveDocumentWithDelegate:(id)delegate didSaveSelector:(SEL)didSaveSelector
contextInfo:(void *)contextInfo;
|
- (void)saveToFile:(NSString *)fileName saveOperation:(NSSaveOperationType)saveOperation
delegate:(id)delegate didSaveSelector:(SEL)didSaveSelector contextInfo:(void *)contextInfo;
|
- (BOOL)shouldChangePrintInfo:(NSPrintInfo *)newPrintInfo;
|
- (BOOL)shouldCloseWindowController:(NSWindowController *)windowController;
|
- (void)shouldCloseWindowController:(NSWindowController *)windowController
delegate:(id)delegate shouldCloseSelector:(SEL)callback contextInfo:(void *)contextInfo;
|
- (BOOL)shouldRunSavePanelWithAccessoryView;
|
- (void)showWindows;
|
- (void)updateChangeCount:(NSDocumentChangeType)change;
|
- (BOOL)validateMenuItem:(NSMenuItem *)anItem;
|
- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem;
|
- (void)windowControllerDidLoadNib:(NSWindowController *)windowController;
|
- (void)windowControllerWillLoadNib:(NSWindowController *)windowController;
|
- (NSArray *)windowControllers;
|
- (NSString *)windowNibName;
|
- (BOOL)writeToFile:(NSString *)fileName ofType:(NSString *)type;
|
- (BOOL)writeToFile:(NSString *)fullDocumentPath ofType:(NSString *)documentTypeName
originalFile:(NSString *)fullOriginalDocumentPath saveOperation:(NSSaveOperationType)saveOperationType;
|
- (BOOL)writeToURL:(NSURL *)url ofType:(NSString *)type;
|
- (BOOL)writeWithBackupToFile:(NSString *)fullDocumentPath ofType:(NSString *)documentTypeName
saveOperation:(NSSaveOperationType)saveOperationType;
|