NSDocumentController

NSDocumentController Mac OS X 10.0

NSDocumentController is one of three classes that make up the document-based application architecture. The other two classes are NSDocument and NSWindowController. This class is responsible for managing an applications documents, in particular providing an implementation for the File Open and File New commands. Additionally, NSDocumentController takes responsibility for ensuring that documents are properly saved and closed before an application terminates.

figs/cocn_1527.gif

@interface NSDocumentController : NSObject <NSCoding>
 // Initializers
   - (id)init;
 // Accessor Methods
   - (void)setShouldCreateUI:(BOOL)flag;
   - (BOOL)shouldCreateUI;
 // Class Methods
   + (id)sharedDocumentController;
 // Instance Methods
   - (BOOL)closeAllDocuments;
   - (NSArray *)URLsFromRunningOpenPanel;
   - (void)addDocument:(NSDocument *)document;
   - (IBAction)clearRecentDocuments:(id)sender;
   - (void)closeAllDocumentsWithDelegate:(id)delegate didCloseAllSelector:(SEL)didAllCloseSelector
        contextInfo:(void *)contextInfo;
   - (NSString *)currentDirectory;
   - (id)currentDocument;
   - (NSString *)displayNameForType:(NSString *)documentTypeName;
   - (Class)documentClassForType:(NSString *)documentTypeName;
   - (id)documentForFileName:(NSString *)fileName;
   - (id)documentForWindow:(NSWindow *)window;
   - (NSArray *)documents;
   - (NSArray *)fileExtensionsFromType:(NSString *)documentTypeName;
   - (NSArray *)fileNamesFromRunningOpenPanel;
   - (BOOL)hasEditedDocuments;
   - (id)makeDocumentWithContentsOfFile:(NSString *)fileName ofType:(NSString *)type;
   - (id)makeDocumentWithContentsOfURL:(NSURL *)url ofType:(NSString *)type;
   - (id)makeUntitledDocumentOfType:(NSString *)type;
   - (IBAction)newDocument:(id)sender;
   - (void)noteNewRecentDocument:(NSDocument *)document;
   - (void)noteNewRecentDocumentURL:(NSURL *)url;
   - (IBAction)openDocument:(id)sender;
   - (id)openDocumentWithContentsOfFile:(NSString *)fileName display:(BOOL)display;
   - (id)openDocumentWithContentsOfURL:(NSURL *)url display:(BOOL)display;
   - (id)openUntitledDocumentOfType:(NSString*)type display:(BOOL)display;
   - (NSArray *)recentDocumentURLs;
   - (void)removeDocument:(NSDocument *)document;
   - (BOOL)reviewUnsavedDocumentsWithAlertTitle:(NSString *)title cancellable:(BOOL)cancellable;
   - (void)reviewUnsavedDocumentsWithAlertTitle:(NSString *)title cancellable:(BOOL)cancellable delegate:(id)delegate
        didReviewAllSelector:(SEL)didReviewAllSelector contextInfo:(void *)contextInfo;
   - (int)runModalOpenPanel:(NSOpenPanel *)openPanel  forTypes:(NSArray *)openableFileExtensions;
   - (IBAction)saveAllDocuments:(id)sender;
   - (NSString *)typeFromFileExtension:(NSString *)fileNameExtensionOrHFSFileType;
   - (BOOL)validateMenuItem:(NSMenuItem *)anItem;
   - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem;
 // Methods Implementing NSCoding
   - (void)encodeWithCoder:(NSCoder *)aCoder;
   - (id)initWithCoder:(NSCoder *)aDecoder;



    Part II: API Quick Reference
    Chapter 13. Foundation Classes