Up

# NSDocument

### Authors

Carl Lindberg (`Carl.Lindberg@hbo.com`)

> The abstract document class

Copyright: (C) 1999 Free Software Foundation, Inc.

# Software documentation for the NSDocument class

## NSDocument : NSObject

> Declared in:
>   AppKit/NSDocument.h

Availability: OpenStep
Description forthcoming.
Method summary

- +isNativeType:
- +readableTypes
- +writableTypes
- -addWindowController:
- -autosaveDocumentWithDelegate:didAutosaveSelector:contextInfo:
- -autosavedContentsFileURL
- -autosavingFileType
- -canCloseDocument
- -canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo:
- -close
- -dataOfType:error:
- -dataRepresentationOfType:
- -displayName
- -fileAttributesToWriteToFile:ofType:saveOperation:
- -fileAttributesToWriteToURL:ofType:forSaveOperation:originalContentsURL:error:
- -fileModificationDate
- -fileName
- -fileNameExtensionForType:saveOperation:
- -fileNameExtensionWasHiddenInLastRunSavePanel
- -fileNameFromRunningSavePanelForSaveOperation:
- -fileType
- -fileTypeFromLastRunSavePanel
- -fileURL
- -fileWrapperOfType:error:
- -fileWrapperRepresentationOfType:
- -hasUnautosavedChanges
- -hasUndoManager
- -init
- -initForURL:withContentsOfURL:ofType:error:
- -initWithContentsOfFile:ofType:
- -initWithContentsOfURL:ofType:
- -initWithContentsOfURL:ofType:error:
- -initWithType:error:
- -isDocumentEdited
- -keepBackupFile
- -lastComponentOfFileName
- -loadDataRepresentation:ofType:
- -loadFileWrapperRepresentation:ofType:
- -makeWindowControllers
- -preparePageLayout:
- -prepareSavePanel:
- -presentError:
- -presentError:modalForWindow:delegate:didPresentSelector:contextInfo:
- -printDocument:
- -printDocumentWithSettings:showPrintPanel:delegate:didPrintSelector:contextInfo:
- -printInfo
- -printOperationWithSettings:error:
- -printShowingPrintPanel:
- -readFromData:ofType:error:
- -readFromFile:ofType:
- -readFromFileWrapper:ofType:error:
- -readFromURL:ofType:
- -readFromURL:ofType:error:
- -removeWindowController:
- -revertDocumentToSaved:
- -revertToContentsOfURL:ofType:error:
- -revertToSavedFromFile:ofType:
- -revertToSavedFromURL:ofType:
- -runModalPageLayoutWithPrintInfo:
- -runModalPageLayoutWithPrintInfo:delegate:didRunSelector:contextInfo:
- -runModalPrintOperation:delegate:didRunSelector:contextInfo:
- -runModalSavePanel:withAccessoryView:
- -runModalSavePanelForSaveOperation:delegate:didSaveSelector:contextInfo:
- -runPageLayout:
- -saveDocument:
- -saveDocumentAs:
- -saveDocumentTo:
- -saveDocumentWithDelegate:didSaveSelector:contextInfo:
- -saveToFile:saveOperation:delegate:didSaveSelector:contextInfo:
- -saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo:
- -saveToURL:ofType:forSaveOperation:error:
- -setAutosavedContentsFileURL:
- -setFileModificationDate:
- -setFileName:
- -setFileType:
- -setFileURL:
- -setHasUndoManager:
- -setLastComponentOfFileName:
- -setPrintInfo:
- -setUndoManager:
- -setWindow:
- -shouldChangePrintInfo:
- -shouldCloseWindowController:
- -shouldCloseWindowController:delegate:shouldCloseSelector:contextInfo:
- -shouldRunSavePanelWithAccessoryView
- -showWindows
- -undoManager
- -updateChangeCount:
- -validateMenuItem:
- -validateUserInterfaceItem:
- -willPresentError:
- -windowControllerDidLoadNib:
- -windowControllerWillLoadNib:
- -windowControllers
- -windowForSheet
- -windowNibName
- -writableTypesForSaveOperation:
- -writeSafelyToURL:ofType:forSaveOperation:error:
- -writeToFile:ofType:
- -writeToFile:ofType:originalFile:saveOperation:
- -writeToURL:ofType:
- -writeToURL:ofType:error:
- -writeToURL:ofType:forSaveOperation:originalContentsURL:error:
- -writeWithBackupToFile:ofType:saveOperation:

### isNativeType:

+ (BOOL) isNativeType: (NSString*)type;
Availability: OpenStep
Description forthcoming.

### readableTypes

+ (NSArray*) readableTypes;
Availability: OpenStep
Description forthcoming.

### writableTypes

+ (NSArray*) writableTypes;
Availability: OpenStep
Description forthcoming.

### addWindowController:

- (void) addWindowController: (NSWindowController*)windowController;
Availability: OpenStep
Description forthcoming.

### autosaveDocumentWithDelegate: didAutosaveSelector: contextInfo:

- (void) autosaveDocumentWithDelegate: (id)delegate didAutosaveSelector: (SEL)didAutosaveSelector contextInfo: (void*)context;
Availability: MacOS-X 10.4.0
Description forthcoming.

### autosavedContentsFileURL

- (NSURL*) autosavedContentsFileURL;
Availability: MacOS-X 10.4.0
Description forthcoming.

### autosavingFileType

- (NSString*) autosavingFileType;
Availability: MacOS-X 10.4.0
Description forthcoming.

### canCloseDocument

- (BOOL) canCloseDocument;
Availability: MacOS-X 10.0.0 removed at MacOS-X 10.4.0
Description forthcoming.

### canCloseDocumentWithDelegate: shouldCloseSelector: contextInfo:

- (void) canCloseDocumentWithDelegate: (id)delegate shouldCloseSelector: (SEL)shouldCloseSelector contextInfo: (void*)contextInfo;
Availability: MacOS-X 10.0.0
Description forthcoming.

### close

- (void) close;
Availability: OpenStep
Closes all the windows owned by the document, then removes itself from the list of documents known by the NSDocumentController. This method does not ask the user if they want to save the document before closing. It is closed without saving any information.

### dataOfType: error:

- (NSData*) dataOfType: (NSString*)type error: (NSError**)error;
Availability: MacOS-X 10.4.0
Description forthcoming.

### dataRepresentationOfType:

- (NSData*) dataRepresentationOfType: (NSString*)type;
Availability: OpenStep
Description forthcoming.

### displayName

- (NSString*) displayName;
Availability: OpenStep
Description forthcoming.

### fileAttributesToWriteToFile: ofType: saveOperation:

- (NSDictionary*) fileAttributesToWriteToFile: (NSString*)fullDocumentPath ofType: (NSString*)docType saveOperation: (NSSaveOperationType)saveOperationType;
Availability: OpenStep
Description forthcoming.

### fileAttributesToWriteToURL: ofType: forSaveOperation: originalContentsURL: error:

- (NSDictionary*) fileAttributesToWriteToURL: (NSURL*)url ofType: (NSString*)type forSaveOperation: (NSSaveOperationType)op originalContentsURL: (NSURL*)original error: (NSError**)error;
Availability: MacOS-X 10.4.0
Description forthcoming.

### fileModificationDate

- (NSDate*) fileModificationDate;
Availability: MacOS-X 10.4.0
Description forthcoming.

### fileName

- (NSString*) fileName;
Availability: OpenStep
Description forthcoming.

### fileNameExtensionForType: saveOperation:

- (NSString*) fileNameExtensionForType: (NSString*)typeName saveOperation: (NSSaveOperationType)saveOperation;
Availability: MacOS-X 10.5.0
Description forthcoming.

### fileNameExtensionWasHiddenInLastRunSavePanel

- (BOOL) fileNameExtensionWasHiddenInLastRunSavePanel;
Availability: MacOS-X 10.1.0
Description forthcoming.

### fileNameFromRunningSavePanelForSaveOperation:

- (NSString*) fileNameFromRunningSavePanelForSaveOperation: (NSSaveOperationType)saveOperation;
Availability: MacOS-X 10.0.0 removed at MacOS-X 10.4.0
Description forthcoming.

### fileType

- (NSString*) fileType;
Availability: OpenStep
Description forthcoming.

### fileTypeFromLastRunSavePanel

- (NSString*) fileTypeFromLastRunSavePanel;
Availability: OpenStep
Description forthcoming.

### fileURL

- (NSURL*) fileURL;
Availability: MacOS-X 10.4.0
Description forthcoming.

### fileWrapperOfType: error:

- (NSFileWrapper*) fileWrapperOfType: (NSString*)type error: (NSError**)error;
Availability: MacOS-X 10.4.0
Description forthcoming.

### fileWrapperRepresentationOfType:

- (NSFileWrapper*) fileWrapperRepresentationOfType: (NSString*)type;
Availability: OpenStep
Description forthcoming.

### hasUnautosavedChanges

- (BOOL) hasUnautosavedChanges;
Availability: MacOS-X 10.4.0
Description forthcoming.

### hasUndoManager

- (BOOL) hasUndoManager;
Availability: OpenStep
Description forthcoming.

### init

- (id) init;
Availability: OpenStep
Description forthcoming.

### initForURL: withContentsOfURL: ofType: error:

- (id) initForURL: (NSURL*)forUrl withContentsOfURL: (NSURL*)url ofType: (NSString*)type error: (NSError**)error;
Availability: MacOS-X 10.4.0
Description forthcoming.

### initWithContentsOfFile: ofType:

- (id) initWithContentsOfFile: (NSString*)fileName ofType: (NSString*)fileType;
Availability: OpenStep
Initialises the receiver with the contents of the document at fileName assuming that the type of data is as specified by fileType.
Destroys the receiver and returns `nil` on failure.

### initWithContentsOfURL: ofType:

- (id) initWithContentsOfURL: (NSURL*)url ofType: (NSString*)fileType;
Availability: OpenStep
Initialises the receiver with the contents of the document at url assuming that the type of data is as specified by fileType.
Destroys the receiver and returns `nil` on failure.

### initWithContentsOfURL: ofType: error:

- (id) initWithContentsOfURL: (NSURL*)url ofType: (NSString*)type error: (NSError**)error;
Availability: MacOS-X 10.4.0
Description forthcoming.

### initWithType: error:

- (id) initWithType: (NSString*)type error: (NSError**)error;
Availability: MacOS-X 10.4.0
Description forthcoming.

### isDocumentEdited

- (BOOL) isDocumentEdited;
Availability: OpenStep
Description forthcoming.

### keepBackupFile

- (BOOL) keepBackupFile;
Availability: OpenStep
Description forthcoming.

### lastComponentOfFileName

- (NSString*) lastComponentOfFileName;
Availability: MacOS-X 10.4.0
Description forthcoming.

### loadDataRepresentation: ofType:

- (BOOL) loadDataRepresentation: (NSData*)data ofType: (NSString*)type;
Availability: OpenStep
Description forthcoming.

### loadFileWrapperRepresentation: ofType:

- (BOOL) loadFileWrapperRepresentation: (NSFileWrapper*)wrapper ofType: (NSString*)type;
Availability: OpenStep
Description forthcoming.

### makeWindowControllers

- (void) makeWindowControllers;
Availability: OpenStep
Creates the window controllers for the current document. Calls addWindowController: on the receiver to add them to the controller array.

### preparePageLayout:

- (BOOL) preparePageLayout: (NSPageLayout*)pageLayout;
Availability: MacOS-X 10.4.0
Description forthcoming.

### prepareSavePanel:

- (BOOL) prepareSavePanel: (NSSavePanel*)savePanel;
Availability: OpenStep
Description forthcoming.

### presentError:

- (BOOL) presentError: (NSError*)error;
Availability: MacOS-X 10.4.0
Description forthcoming.

### presentError: modalForWindow: delegate: didPresentSelector: contextInfo:

- (void) presentError: (NSError*)error modalForWindow: (NSWindow*)window delegate: (id)delegate didPresentSelector: (SEL)sel contextInfo: (void*)context;
Availability: MacOS-X 10.4.0
Description forthcoming.

### printDocument:

- (IBAction) printDocument: (id)sender;
Availability: OpenStep
Description forthcoming.

### printDocumentWithSettings: showPrintPanel: delegate: didPrintSelector: contextInfo:

- (void) printDocumentWithSettings: (NSDictionary*)settings showPrintPanel: (BOOL)flag delegate: (id)delegate didPrintSelector: (SEL)sel contextInfo: (void*)context;
Availability: MacOS-X 10.4.0
Description forthcoming.

### printInfo

- (NSPrintInfo*) printInfo;
Availability: OpenStep
Description forthcoming.

### printOperationWithSettings: error:

- (NSPrintOperation*) printOperationWithSettings: (NSDictionary*)settings error: (NSError**)error;
Availability: MacOS-X 10.4.0
Description forthcoming.

### printShowingPrintPanel:

- (void) printShowingPrintPanel: (BOOL)flag;
Availability: OpenStep
Description forthcoming.

### readFromData: ofType: error:

- (BOOL) readFromData: (NSData*)data ofType: (NSString*)type error: (NSError**)error;
Availability: MacOS-X 10.4.0
Description forthcoming.

### readFromFile: ofType:

- (BOOL) readFromFile: (NSString*)fileName ofType: (NSString*)type;
Availability: OpenStep
Description forthcoming.

### readFromFileWrapper: ofType: error:

- (BOOL) readFromFileWrapper: (NSFileWrapper*)wrapper ofType: (NSString*)type error: (NSError**)error;
Availability: MacOS-X 10.4.0
Description forthcoming.

### readFromURL: ofType:

- (BOOL) readFromURL: (NSURL*)url ofType: (NSString*)type;
Availability: OpenStep
Description forthcoming.

### readFromURL: ofType: error:

- (BOOL) readFromURL: (NSURL*)url ofType: (NSString*)type error: (NSError**)error;
Availability: MacOS-X 10.4.0
Description forthcoming.

### removeWindowController:

- (void) removeWindowController: (NSWindowController*)windowController;
Availability: OpenStep
Description forthcoming.

### revertDocumentToSaved:

- (IBAction) revertDocumentToSaved: (id)sender;
Availability: OpenStep
Description forthcoming.

### revertToContentsOfURL: ofType: error:

- (BOOL) revertToContentsOfURL: (NSURL*)url ofType: (NSString*)type error: (NSError**)error;
Availability: MacOS-X 10.4.0
Description forthcoming.

### revertToSavedFromFile: ofType:

- (BOOL) revertToSavedFromFile: (NSString*)fileName ofType: (NSString*)type;
Availability: OpenStep
Description forthcoming.

### revertToSavedFromURL: ofType:

- (BOOL) revertToSavedFromURL: (NSURL*)url ofType: (NSString*)type;
Availability: OpenStep
Description forthcoming.

### runModalPageLayoutWithPrintInfo:

- (NSInteger) runModalPageLayoutWithPrintInfo: (NSPrintInfo*)printInfo;
Availability: OpenStep
Description forthcoming.

### runModalPageLayoutWithPrintInfo: delegate: didRunSelector: contextInfo:

- (void) runModalPageLayoutWithPrintInfo: (NSPrintInfo*)info delegate: (id)delegate didRunSelector: (SEL)sel contextInfo: (void*)context;
Availability: MacOS-X 10.4.0
Description forthcoming.

### runModalPrintOperation: delegate: didRunSelector: contextInfo:

- (void) runModalPrintOperation: (NSPrintOperation*)op delegate: (id)delegate didRunSelector: (SEL)sel contextInfo: (void*)context;
Availability: MacOS-X 10.4.0
Description forthcoming.

### runModalSavePanel: withAccessoryView:

- (NSInteger) runModalSavePanel: (NSSavePanel*)savePanel withAccessoryView: (NSView*)accessoryView;
Availability: MacOS-X 10.0.0 removed at MacOS-X 10.4.0
Description forthcoming.

### runModalSavePanelForSaveOperation: delegate: didSaveSelector: contextInfo:

- (void) runModalSavePanelForSaveOperation: (NSSaveOperationType)saveOperation delegate: (id)delegate didSaveSelector: (SEL)didSaveSelector contextInfo: (void*)contextInfo;
Availability: OpenStep
Description forthcoming.

### runPageLayout:

- (IBAction) runPageLayout: (id)sender;
Availability: OpenStep
Description forthcoming.

### saveDocument:

- (IBAction) saveDocument: (id)sender;
Availability: OpenStep
Description forthcoming.

### saveDocumentAs:

- (IBAction) saveDocumentAs: (id)sender;
Availability: OpenStep
Description forthcoming.

### saveDocumentTo:

- (IBAction) saveDocumentTo: (id)sender;
Availability: OpenStep
Description forthcoming.

### saveDocumentWithDelegate: didSaveSelector: contextInfo:

- (void) saveDocumentWithDelegate: (id)delegate didSaveSelector: (SEL)didSaveSelector contextInfo: (void*)contextInfo;
Availability: OpenStep
Description forthcoming.

### saveToFile: saveOperation: delegate: didSaveSelector: contextInfo:

- (void) saveToFile: (NSString*)fileName saveOperation: (NSSaveOperationType)saveOperation delegate: (id)delegate didSaveSelector: (SEL)didSaveSelector contextInfo: (void*)contextInfo;
Availability: OpenStep
Description forthcoming.

### saveToURL: ofType: forSaveOperation: delegate: didSaveSelector: contextInfo:

- (void) saveToURL: (NSURL*)url ofType: (NSString*)type forSaveOperation: (NSSaveOperationType)op delegate: (id)delegate didSaveSelector: (SEL)didSaveSelector contextInfo: (void*)contextInfo;
Availability: MacOS-X 10.4.0
Description forthcoming.

### saveToURL: ofType: forSaveOperation: error:

- (BOOL) saveToURL: (NSURL*)url ofType: (NSString*)type forSaveOperation: (NSSaveOperationType)op error: (NSError**)error;
Availability: MacOS-X 10.4.0
Description forthcoming.

### setAutosavedContentsFileURL:

- (void) setAutosavedContentsFileURL: (NSURL*)url;
Availability: MacOS-X 10.4.0
Description forthcoming.

### setFileModificationDate:

- (void) setFileModificationDate: (NSDate*)date;
Availability: MacOS-X 10.4.0
Description forthcoming.

### setFileName:

- (void) setFileName: (NSString*)fileName;
Availability: OpenStep
Description forthcoming.

### setFileType:

- (void) setFileType: (NSString*)type;
Availability: OpenStep
Description forthcoming.

### setFileURL:

- (void) setFileURL: (NSURL*)url;
Availability: MacOS-X 10.4.0
Description forthcoming.

### setHasUndoManager:

- (void) setHasUndoManager: (BOOL)flag;
Availability: OpenStep
Description forthcoming.

### setLastComponentOfFileName:

- (void) setLastComponentOfFileName: (NSString*)str;
Availability: MacOS-X 10.4.0
Description forthcoming.

### setPrintInfo:

- (void) setPrintInfo: (NSPrintInfo*)printInfo;
Availability: OpenStep
Description forthcoming.

### setUndoManager:

- (void) setUndoManager: (NSUndoManager*)undoManager;
Availability: OpenStep
Description forthcoming.

### setWindow:

- (void) setWindow: (NSWindow*)aWindow;
Availability: OpenStep
Description forthcoming.

### shouldChangePrintInfo:

- (BOOL) shouldChangePrintInfo: (NSPrintInfo*)newPrintInfo;
Availability: OpenStep
Description forthcoming.

### shouldCloseWindowController:

- (BOOL) shouldCloseWindowController: (NSWindowController*)windowController;
Availability: MacOS-X 10.0.0 removed at MacOS-X 10.4.0
Description forthcoming.

### shouldCloseWindowController: delegate: shouldCloseSelector: contextInfo:

- (void) shouldCloseWindowController: (NSWindowController*)windowController delegate: (id)delegate shouldCloseSelector: (SEL)callback contextInfo: (void*)contextInfo;
Availability: MacOS-X 10.0.0
Description forthcoming.

### shouldRunSavePanelWithAccessoryView

- (BOOL) shouldRunSavePanelWithAccessoryView;
Availability: OpenStep
Description forthcoming.

### showWindows

- (void) showWindows;
Availability: OpenStep
Makes all the documents windows visible by ordering them to the front and making them main or key.
If the document has no windows, this method has no effect.

### undoManager

- (NSUndoManager*) undoManager;
Availability: OpenStep
Description forthcoming.

### updateChangeCount:

- (void) updateChangeCount: (NSDocumentChangeType)change;
Availability: OpenStep
Description forthcoming.

### validateMenuItem:

- (BOOL) validateMenuItem: (NSMenuItem*)anItem;
Availability: OpenStep
Description forthcoming.

### validateUserInterfaceItem:

- (BOOL) validateUserInterfaceItem: (id)anItem;
Availability: OpenStep
Description forthcoming.

### willPresentError:

- (NSError*) willPresentError: (NSError*)error;
Availability: MacOS-X 10.4.0
Description forthcoming.

### windowControllerDidLoadNib:

- (void) windowControllerDidLoadNib: (NSWindowController*)windowController;
Availability: OpenStep
Description forthcoming.

### windowControllerWillLoadNib:

- (void) windowControllerWillLoadNib: (NSWindowController*)windowController;
Availability: OpenStep
Description forthcoming.

### windowControllers

- (NSArray*) windowControllers;
Availability: OpenStep
Description forthcoming.

### windowForSheet

- (NSWindow*) windowForSheet;
Availability: MacOS-X 10.3.0
Description forthcoming.

### windowNibName

- (NSString*) windowNibName;
Availability: OpenStep
Description forthcoming.

### writableTypesForSaveOperation:

- (NSArray*) writableTypesForSaveOperation: (NSSaveOperationType)op;
Availability: MacOS-X 10.4.0
Description forthcoming.

### writeSafelyToURL: ofType: forSaveOperation: error:

- (BOOL) writeSafelyToURL: (NSURL*)url ofType: (NSString*)type forSaveOperation: (NSSaveOperationType)op error: (NSError**)error;
Availability: MacOS-X 10.4.0
Description forthcoming.

### writeToFile: ofType:

- (BOOL) writeToFile: (NSString*)fileName ofType: (NSString*)type;
Availability: OpenStep
Description forthcoming.

### writeToFile: ofType: originalFile: saveOperation:

- (BOOL) writeToFile: (NSString*)fileName ofType: (NSString*)type originalFile: (NSString*)origFileName saveOperation: (NSSaveOperationType)saveOp;
Availability: OpenStep
Description forthcoming.

### writeToURL: ofType:

- (BOOL) writeToURL: (NSURL*)url ofType: (NSString*)type;
Availability: OpenStep
Description forthcoming.

### writeToURL: ofType: error:

- (BOOL) writeToURL: (NSURL*)url ofType: (NSString*)type error: (NSError**)error;
Availability: MacOS-X 10.4.0
Description forthcoming.

### writeToURL: ofType: forSaveOperation: originalContentsURL: error:

- (BOOL) writeToURL: (NSURL*)url ofType: (NSString*)type forSaveOperation: (NSSaveOperationType)op originalContentsURL: (NSURL*)orig error: (NSError**)error;
Availability: MacOS-X 10.4.0
Description forthcoming.

### writeWithBackupToFile: ofType: saveOperation:

- (BOOL) writeWithBackupToFile: (NSString*)fileName ofType: (NSString*)fileType saveOperation: (NSSaveOperationType)saveOp;
Availability: OpenStep
Description forthcoming.

Up