NSDocumentController Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.0 and later. |
| Companion guide | |
| Declared in | NSDocumentController.h |
Overview
An NSDocumentController object manages an application’s documents. As the first-responder target of New and Open menu commands, it creates and opens documents and tracks them throughout a session of the application. When opening documents, an NSDocumentController runs and manages the modal Open panel. NSDocumentController objects also maintain and manage the mappings of document types, extensions, and NSDocument subclasses as specified in the CFBundleDocumentTypes property loaded from the information property list (Info.plist).
You can use various NSDocumentController methods to get a list of the current documents; get the current document (which is the document whose window is currently key); get documents based on a given filename or window; and find out about a document’s extension, type, display name, and document class.
In some situations, it is worthwhile to subclass NSDocumentController in non-NSDocument-based applications to get some of its features. For example, the NSDocumentController management of the Open Recent menu is useful in applications that don’t use subclasses of NSDocument.
Adopted Protocols
Tasks
Obtaining the Shared Document Controller
Initializing a New NSDocumentController
Creating and Opening Documents
-
– documentForURL: -
– duplicateDocumentWithContentsOfURL:copying:displayName:error: -
– openDocumentWithContentsOfURL:display:completionHandler: -
– openUntitledDocumentAndDisplay:error: -
– makeDocumentForURL:withContentsOfURL:ofType:error: -
– makeDocumentWithContentsOfURL:ofType:error: -
– makeUntitledDocumentOfType:error: -
– reopenDocumentForURL:withContentsOfURL:display:completionHandler:
Managing Documents
-
– documents -
– addDocument: -
– currentDocument -
– documentForWindow: -
– hasEditedDocuments -
– removeDocument:
Managing Document Types
-
– documentClassNames -
– defaultType -
– documentClassForType: -
– displayNameForType: -
– typeForContentsOfURL:error:
Autosaving
Closing Documents
-
– closeAllDocumentsWithDelegate:didCloseAllSelector:contextInfo: -
– reviewUnsavedDocumentsWithAlertTitle:cancellable:delegate:didReviewAllSelector:contextInfo:
Responding to Action Messages
Managing the Open Panel
Managing the Open Recent Menu
-
– maximumRecentDocumentCount -
– clearRecentDocuments: -
– noteNewRecentDocumentURL: -
– noteNewRecentDocument: -
– recentDocumentURLs
Validating User Interface Items
Handling Errors
-
– presentError: -
– presentError:modalForWindow:delegate:didPresentSelector:contextInfo: -
– willPresentError:
Deprecated Methods
-
– fileExtensionsFromType:Deprecated in OS X v10.5 -
– typeFromFileExtension:Deprecated in OS X v10.5 -
– openDocumentWithContentsOfURL:display:error:Deprecated in OS X v10.7 -
– reopenDocumentForURL:withContentsOfURL:error:Deprecated in OS X v10.7 -
– documentForFileName:Deprecated in OS X v10.4 -
– fileNamesFromRunningOpenPanelDeprecated in OS X v10.4 -
– makeDocumentWithContentsOfFile:ofType:Deprecated in OS X v10.4 -
– makeDocumentWithContentsOfURL:ofType:Deprecated in OS X v10.4 -
– makeUntitledDocumentOfType:Deprecated in OS X v10.4 -
– openDocumentWithContentsOfFile:display:Deprecated in OS X v10.4 -
– openDocumentWithContentsOfURL:display:Deprecated in OS X v10.4 -
– openUntitledDocumentOfType:display:Deprecated in OS X v10.4 -
– setShouldCreateUI:Deprecated in OS X v10.4 -
– shouldCreateUIDeprecated in OS X v10.4
Class Methods
sharedDocumentController
Returns the shared NSDocumentController instance.
Return Value
The shared NSDocumentController instance.
Discussion
If an NSDocumentController instance doesn’t exist yet, it is created.
Initialization reads in the document types from the CFBundleDocumentTypes property list (in Info.plist), registers the instance for NSWorkspaceWillPowerOffNotifications, and turns on the flag indicating that document user interfaces should be visible. You should always obtain your application’s NSDocumentController using this method.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDocumentController.hInstance Methods
addDocument:
Adds the given document to the list of open documents.
Discussion
The open... methods automatically call addDocument:. This method is mostly provided for subclasses that want to know when documents arrive.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDocumentController.hautosavingDelay
Returns the time interval in seconds for periodic autosaving.
Discussion
A value of 0 indicates that periodic autosaving should not be done at all. NSDocumentController uses this number as the amount of time to wait between detecting that a document has unautosaved changes and sending the document an autosaveDocumentWithDelegate:didAutosaveSelector:contextInfo: message. The default value is 0.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSDocumentController.hclearRecentDocuments:
Empties the recent documents list for the application.
Discussion
This is the action for the Clear menu command, but it can be invoked directly if necessary.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDocumentController.hcloseAllDocumentsWithDelegate:didCloseAllSelector:contextInfo:
Iterates through all the open documents and tries to close them one by one using the specified delegate.
Discussion
Each NSDocument object is sent canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo:, which, if the document is dirty, gives it a chance to refuse to close or to save itself first. This method may ask whether to save or to perform a save.
The didCloseAllSelector callback method is invoked with YES if all documents are closed, and NO otherwise. Pass the contextInfo object with the callback. The didCloseAllSelector callback method should have the following signature:
- (void)documentController:(NSDocumentController *)docController didCloseAll: (BOOL)didCloseAll contextInfo:(void *)contextInfo |
Availability
- Available in OS X v10.0 and later.
Declared In
NSDocumentController.hcurrentDirectory
Returns the directory path to be used as the starting point in the Open panel.
Discussion
The first valid directory from the following list is returned:
The directory location where the current document was last saved
The last directory visited in the Open panel
The user’s home directory
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDocumentController.hcurrentDocument
Returns the NSDocument object associated with the main window.
Discussion
This method returns nil if it is called when its application is not active. This can occur during processing of a drag-and-drop operation, for example, in an implementation of readSelectionFromPasteboard:. In such a case, send the following message instead from an NSView subclass associated with the document:
[[[self window] windowController] document]; |
Availability
- Available in OS X v10.0 and later.
Declared In
NSDocumentController.hdefaultType
Returns the name of the document type that should be used when creating new documents.
Discussion
The default implementation of this method returns the first Editor type declared by the CFBundleDocumentTypes array in the application's Info.plist, or returns nil if no Editor type is declared. You can override it to customize the type of document that is created when, for instance, the user chooses New in the File menu.
Availability
- Available in OS X v10.4 and later.
Declared In
NSDocumentController.hdisplayNameForType:
Returns the descriptive name for the specified document type, which is used in the File Format pop-up menu of the Save As dialog.
Parameters
- documentTypeName
The name of a document type, specified by
CFBundleTypeNamein the application’sInfo.plistfile.
Return Value
The descriptive name for the document type specified by documentTypeName. If there is no descriptive name, returns documentTypeName.
Discussion
For a document-based application, supported document types are specified in the Info.plist file by the CFBundleDocumentTypes array. Each document type is specified by a dictionary in this array, and is named by the CFBundleTypeName attribute. You can provide a descriptive, localized, representation of this name by providing a corresponding entry in the InfoPlist.strings file(s). For example, given an Info.plist file that contains the following fragment:
<dict> |
<key>CFBundleDocumentTypes</key> |
<array> |
<dict> |
<key>CFBundleTypeName</key> |
<string>BinaryFile</string> |
<key>CFBundleTypeExtensions</key> |
<array> |
<string>binary</string> |
</array> |
you could provide a descriptive name by adding an entry in the InfoPlist.strings file:
BinaryFile = "Binary file format"; |
Availability
- Available in OS X v10.0 and later.
Declared In
NSDocumentController.hdocumentClassForType:
Returns the NSDocument subclass associated with a given document type.
Parameters
- documentTypeName
The name of a document type, specified by
CFBundleTypeNamein the application’sInfo.plistfile.The document type must be one the receiver can read.
Return Value
Returns the NSDocument subclass associated with documentTypeName. If the class cannot be found, returns nil.
Discussion
Para
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDocumentController.hdocumentClassNames
Returns the names of NSDocument subclasses supported by this application.
Return Value
The names of NSDocument subclasses supported by this application.
Discussion
The default implementation of this method returns information derived from the application's Info.plist property list file. You can override it to return the names of document classes that are dynamically loaded from plugins.
Availability
- Available in OS X v10.4 and later.
Declared In
NSDocumentController.hdocumentForURL:
Returns, for a given URL, the open document whose file or file package is located by the URL, or nil if there is no such open document.
Discussion
The default implementation of this method queries each open document to find one whose URL matches, and returns the first one whose URL does match.
For backward binary compatibility with OS X v10.3 and earlier, the default implementation of this method instead invokes documentForFileName: if it is overridden and the URL uses the file: scheme.
Availability
- Available in OS X v10.4 and later.
Declared In
NSDocumentController.hdocumentForWindow:
Returns the document object whose window controller owns a specified window.
Return Value
The document object whose window controller owns window. Returns nil if window is nil, if window has no window controller, or if the window controller does not have an association with an instance of NSDocument.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDocumentController.hdocuments
Returns the NSDocument objects managed by the receiver.
Return Value
The NSDocument objects managed by the receiver. If there are currently no documents, returns an empty NSArray object.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDocumentController.hduplicateDocumentWithContentsOfURL:copying:displayName:error:
Creates a new document by reading the contents for the document from another URL, presents its user interface, and returns the document if successful.
Parameters
- url
The URL locating the document from which contents of the new document are copied.
- duplicateByCopying
If
YES, the contents located at the passed-in URL are copied into a file located in the directory used for the autosaved contents of untitled documents.- displayNameOrNil
If not
nilthen this value is used to derive a display name for the new document that does not match one that is already in use by an open document.- outError
On return, if duplication is unsuccessful, a pointer to an error object that encapsulates the reason the document could not be created.
Return Value
The newly created NSDocument object, or, if the document could not be created, nil.
Discussion
The default implementation of this method copies the file if specified, determines the type of the document, invokes makeDocumentForURL:withContentsOfURL:ofType:error: to instantiate it, sends the document setDisplayName: to name it if displayNameOrNil is not nil, invokes addDocument: to record its opening, and sends the document makeWindowControllers and showWindows messages.
The default implementation of this method uses the file coordination mechanism that was added to the Foundation framework in Mac OS 10.7. It passes the document to the NSFileCoordinator method addFilePresenter: right after invoking addDocument:. (The balancing invocation of the NSFileCoordinator method removeFilePresenter: is in the NSDocument method close.)
You can override this method to customize how documents are duplicated. It is invoked by the NSDocument method duplicateAndReturnError:. It may also be invoked from other places in AppKit.
Applications probably do not need to invoke this method directly.
Availability
- Available in OS X v10.7 and later.
Declared In
NSDocumentController.hhasEditedDocuments
Returns a Boolean value that indicates whether the receiver has any documents with unsaved changes.
Return Value
YES if the receiver has any documents with unsaved changes, otherwise NO.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDocumentController.hinit
This method is the designated initializer for NSDocumentController.
Discussion
The first instance of NSDocumentController or any of its subclasses that is created becomes the shared instance.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDocumentController.hmakeDocumentForURL:withContentsOfURL:ofType:error:
Instantiates a document located by a URL, of a specified type, but by reading the contents for the document from another URL, and returns it if successful.
Discussion
The URL is specified by absoluteDocumentURL, the type by typeName, and the other URL providing the contents by absoluteDocumentContentsURL. If not successful, the method returns nil after setting outError to point to an NSError object that encapsulates the reason why the document could not be instantiated. The default implementation of this method invokes documentClassForType: to find out the class of document to instantiate, allocates a document object, and initializes it by sending it an initForURL:withContentsOfURL:ofType:error: message.
Availability
- Available in OS X v10.4 and later.
Declared In
NSDocumentController.hmakeDocumentWithContentsOfURL:ofType:error:
Instantiates a document located by a URL, of a specified type, and returns it if successful.
Discussion
The URL is specified by absoluteURL and the document type by typeName. If not successful, the method returns nil after setting outError to point to an NSError that encapsulates the reason why the document could not be instantiated. The default implementation of this method invokes documentClassForType: to find out the class of document to instantiate, allocates a document object, and initializes it by sending it an initWithContentsOfURL:ofType:error: message.
For backward binary compatibility with OS X v10.3 and earlier, the default implementation of this method instead invokes makeDocumentWithContentsOfFile:ofType: if it is overridden and the URL uses the file: scheme.
Availability
- Available in OS X v10.4 and later.
Declared In
NSDocumentController.hmakeUntitledDocumentOfType:error:
Instantiates a new untitled document of the specified type and returns it if successful.
Discussion
The document type is specified by typeName. If not successful, the method returns nil after setting outError to point to an NSError object that encapsulates the reason why a new untitled document could not be instantiated. The default implementation of this method invokes documentClassForType: to find out the class of document to instantiate, then allocates and initializes a document by sending it initWithType:error:.
For backward binary compatibility with OS X v10.3 and earlier, the default implementation of this method instead invokes makeUntitledDocumentOfType: if it is overridden.
Availability
- Available in OS X v10.4 and later.
Declared In
NSDocumentController.hmaximumRecentDocumentCount
Returns the maximum number of items that may be presented in the standard Open Recent menu.
Discussion
A value of 0 indicates that NSDocumentController will not attempt to add an Open Recent menu to your application's File menu, although NSDocumentController will not attempt to remove any preexisting Open Recent menu item. The default implementation returns a value that is subject to change and may or may not be derived from a setting made by the user in System Preferences.
Availability
- Available in OS X v10.4 and later.
Declared In
NSDocumentController.hnewDocument:
An action method invoked by the New menu command, this method creates a new NSDocument object and adds it to the list of such objects managed by the document controller.
Discussion
This method invokes openUntitledDocumentAndDisplay:error:.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDocumentController.hnoteNewRecentDocument:
This method is called by NSDocument objects at appropriate times for managing the recent-documents list.
Discussion
This method constructs a URL and calls noteNewRecentDocumentURL:. Subclasses might override this method to prevent certain documents or kinds of documents from getting into the list.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDocumentController.hnoteNewRecentDocumentURL:
This method should be called by applications not based on NSDocument when they open or save documents identified by the given URL.
Discussion
NSDocument automatically calls this method when appropriate for NSDocument-based applications. Applications not based on NSDocument must also implement the application:openFile: method in the application delegate to handle requests from the Open Recent menu command. You can override this method in an NSDocument-based application to prevent certain kinds of documents from getting into the list (but you have to identify them by URL).
Availability
- Available in OS X v10.0 and later.
Declared In
NSDocumentController.hopenDocument:
An action method invoked by the Open menu command, it runs the modal Open panel and, based on the selected filenames, creates one or more NSDocument objects from the contents of the files.
Discussion
The method adds the newly created objects to the list of NSDocument objects managed by the document controller. This method invokes openDocumentWithContentsOfURL:display:completionHandler:, which actually creates the NSDocument objects.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDocumentController.hopenDocumentWithContentsOfURL:display:completionHandler:
Opens a document located by a URL, optionally presents its user interface, and invokes the passed-in completion handler.
Parameters
- url
The URL locating the document to open.
- displayDocument
If
YES, displays the document’s user interface.- completionHandler
The completion handler block object passed in to be invoked at some point in the future, perhaps after the method invocation has returned. The completion handler must be invoked on the main thread.
The block takes three arguments:
documentThe document that was opened, if successful. Otherwise,
nil.documentWasAlreadyOpenWhether the document was already open or being opened when this method was invoked.
errorIf not successful, an
NSErrorobject that encapsulates the reason why the document could not be opened.
Discussion
The default implementation of this method checks to see if the document is already open or being opened, and if it is not determines the type of the document, invokes makeDocumentWithContentsOfURL:ofType:error: to instantiate it, invokes addDocument: to record its opening, and sends the document a makeWindowControllers message, and, if displayDocument is YES, showWindows. If the document is already open, the method just sends it a showWindows message if displayDocument is YES. If the relevant document class returns YES when sent canConcurrentlyReadDocumentsOfType: then the invocation of makeDocumentWithContentsOfURL:ofType:error: is done on a thread other than the main one, and when that has returned, the rest of the operation is done on the main thread.
The default implementation of this method uses the file coordination mechanism that was added to the Foundation framework in Mac OS 10.7. All of the work it does is one big coordinated read, and it passes the document to the NSFileCoordinator method addFilePresenter: right after invoking addDocument:. (The balancing invocation of the NSFileCoordinator method removeFilePresenter: is in the NSDocument method close.)
You can override this method to customize how documents are opened. Its implementation however is somewhat complex so unless your customization is to do additional work before invoking super, or to invoke super with a completion handler that does additional work before invoking the original completion handler, you should investigate overriding one of the methods that it invokes instead. If you do override this method you should investigate whether you should also override reopenDocumentForURL:withContentsOfURL:display:completionHandler: to apply the same customization. In either case, take care to always invoke the completion handler on the main thread.
You can invoke this method to open a document.
For backward binary compatibility with Mac OS 10.6 and earlier, the default implementation of this method invokes [self openDocumentWithContentsOfURL:url display:displayDocument error:&anError] if that method or the even older openDocumentWithContentsOfFile:display: method is overridden and this one is not, instead of invoking makeDocumentWithContentsOfURL:ofType:error: and all the rest.
Availability
- Available in OS X v10.7 and later.
Declared In
NSDocumentController.hopenUntitledDocumentAndDisplay:error:
Creates a new untitled document, presents its user interface if displayDocument is YES, and returns the document if successful.
Discussion
If not successful, the method returns nil after setting outError to point to an NSError that encapsulates the reason why a new untitled document could not be created.
The default implementation of this method invokes defaultType to determine the type of new document to create, invokes makeUntitledDocumentOfType:error: to create it, then invokes addDocument: to record its opening. If displayDocument is YES, it then sends the new document makeWindowControllers and showWindows messages.
For backward binary compatibility with OS X v10.3 and earlier, the default implementation of this method instead invokes openUntitledDocumentOfType:display: if it is overridden.
Availability
- Available in OS X v10.4 and later.
Declared In
NSDocumentController.hpresentError:
Presents an error alert to the user as a modal panel.
Discussion
Returns YES if error recovery was done, NO otherwise. This method does not return until the user dismisses the alert and, if the error has recovery options and a recovery delegate, the error's recovery delegate is sent an attemptRecoveryFromError:optionIndex: message.
The default NSDocumentController implementation of this method is equivalent to that of NSResponder while treating the application object as the next responder and forwarding error presentation messages to it. (The default NSDocument implementation of this method treats the shared NSDocumentController instance as the next responder and forwards these messages to it.) The default implementations of several NSDocumentController methods invoke this method.
The default implementation of this method invokes willPresentError: to give subclasses an opportunity to customize error presentation. You should not override this method but should instead override willPresentError:.
Availability
- Available in OS X v10.4 and later.
Declared In
NSDocumentController.hpresentError:modalForWindow:delegate:didPresentSelector:contextInfo:
Presents an error alert to the user as a modal panel.
Discussion
When the user dismisses the alert and any recovery possible for the error and chosen by the user has been attempted, sends the message didPresentSelector to the specified delegate. The method selected by didPresentSelector must have the same signature as:
- (void)didPresentErrorWithRecovery:(BOOL)didRecover contextInfo:(void *)contextInfo; |
The default NSDocumentController implementation of this method is equivalent to that of NSResponder while treating the application object as the next responder and forwarding error presentation messages to it. (The default NSDocument implementation of this method treats the shared NSDocumentController instance as the next responder and forwards these messages to it.)
The default implementation of this method invokes willPresentError: to give subclasses an opportunity to customize error presentation. You should not override this method but should instead override willPresentError:.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSDocumentController.hrecentDocumentURLs
Returns the list of recent-document URLs.
Discussion
This method is not a good one to override since the internals of NSDocumentController do not generally use it.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDocumentController.hremoveDocument:
Removes the given document from the list of open documents.
Discussion
A document will automatically call removeDocument: when it closes. This method is mostly provided for subclasses that want to know when documents close.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDocumentController.hreopenDocumentForURL:withContentsOfURL:display:completionHandler:
Reopens a document, optionally located by a URL, by reading the contents for the document from another URL, optionally presents its user interface, and invokes the passed-in completion handler.
Parameters
- urlOrNil
The URL locating the reopened document, unless
nil. Anilparameter value indicates that the reopened document is to have nofileURL, like an untitled document.- contentsURL
The URL (which may or may not be different from the URL of the reopened document) of the document from which the contents are read.
- displayDocument
If
YES, displays the document’s user interface.- completionHandler
The completion handler block object passed in to be invoked at some point in the future, perhaps after the method invocation has returned. The completion handler must be invoked on the main thread.
The block takes three arguments:
documentThe document that was opened, if successful. Otherwise,
nil.documentWasAlreadyOpenWhether the document was already open or being opened when this method was invoked.
errorIf not successful, an
NSErrorobject that encapsulates the reason why the document could not be opened.
Discussion
The default implementation of this method is very similar to openDocumentWithContentsOfURL:display:completionHandler:, the primary difference being that it invokes makeDocumentForURL:withContentsOfURL:ofType:error: instead of makeDocumentWithContentsOfURL:ofType:error:.
You can override this method to customize how documents are reopened during application launching by the restorable state mechanism introduced in Mac OS 10.7. Its implementation, however, is somewhat complex so, unless your customization is to do additional work before invoking super or invoke super with a completion handler that does additional work before invoking the original completion handler, you should investigate overriding one of the methods that it invokes instead.
Applications probably do not need to invoke this method directly.
For backward binary compatibility with Mac OS 10.6 and earlier, the default implementation of this method invokes [self reopenDocumentForURL:url withContentsOfURL:contentsURL error:&anError] if that method is overridden and this one is not, instead of invoking makeDocumentForURL:withContentsOfURL:ofType:error: and all the rest.
Availability
- Available in OS X v10.7 and later.
Declared In
NSDocumentController.hreviewUnsavedDocumentsWithAlertTitle:cancellable:delegate:didReviewAllSelector:contextInfo:
Displays an alert dialog asking if the user wants to review unsaved documents (only if there are two or more unsaved documents), quit regardless of unsaved documents, or (if the choice is allowed) cancel the impending save operation.
Discussion
Assigns delegate to the panel. Invokes didReviewAllSelector with YES if quit without saving is chosen or if there are no dirty documents, and NO otherwise. If the user selects the “Review Unsaved” option, closeAllDocumentsWithDelegate:didCloseAllSelector:contextInfo: is invoked. This method is invoked when the user chooses the Quit menu command, and also when the computer power is being turned off. Note that title is ignored. Pass the contextInfo object with the callback.
The didReviewAllSelector callback method should have the following signature:
- (void)documentController:(NSDocumentController *)docController didReviewAll: (BOOL)didReviewAll contextInfo:(void *)contextInfo |
Availability
- Available in OS X v10.0 and later.
Declared In
NSDocumentController.hrunModalOpenPanel:forTypes:
Invokes the NSOpenPanel runModalForTypes: method, passing the openPanel object and the file extensions associated with a document type.
Discussion
This method is invoked by the URLsFromRunningOpenPanel method. The extensions parameter may also contain encoded HFS file types as well as filename extensions.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDocumentController.hsaveAllDocuments:
As the action method invoked by the Save All command, saves all open documents of the application that need to be saved.
Availability
- Available in OS X v10.0 and later.
See Also
-
saveDocument:(NSDocument)
Declared In
NSDocumentController.hsetAutosavingDelay:
Sets the time interval in seconds for periodic autosaving.
Discussion
A value of 0 indicates that periodic autosaving should not be done at all. NSDocumentController uses this number as the amount of time to wait between detecting that a document has unautosaved changes and sending the document an autosaveDocumentWithDelegate:didAutosaveSelector:contextInfo: message. The default value is 0.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSDocumentController.htypeForContentsOfURL:error:
Returns, for a specified URL, the name of the document type that should be used when opening the document at that location, if successful.
Discussion
The URL is represented by absoluteURL. If not successful, the method returns nil after setting outError to point to an NSError object that encapsulates the reason why the document type could not be determined, or the fact that the document type is unrecognized.
You can override this method to customize type determination for documents being opened.
Availability
- Available in OS X v10.4 and later.
Declared In
NSDocumentController.hURLsFromRunningOpenPanel
Creates an NSOpenPanel instance and initializes it appropriately.
Discussion
This method uses runModalOpenPanel:forTypes: to run the open panel. Returns the chosen files as an array of URLs. Returns nil if the user cancels the Open panel or makes no selection.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDocumentController.hvalidateUserInterfaceItem:
Returns a Boolean value that indicates whether a given user interface item should be enabled.
Parameters
Discussion
Subclasses can override this method to perform additional validations. Subclasses should call super in their implementation for items they don’t handle themselves.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDocumentController.hwillPresentError:
Called when the receiver is about to present an error, returns the error that should actually be presented.
Discussion
The default implementation of this method merely returns the passed-in error. The returned error may simply be forwarded to the application object.
You can override this method to customize the presentation of errors by examining the passed-in error and, for example, returning more specific information. When you override this method always check the NSError object's domain and code to discriminate between errors whose presentation you want to customize and those you don't. For errors you don't want to customize, call the superclass implementation, passing the original error.
Availability
- Available in OS X v10.4 and later.
Declared In
NSDocumentController.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-01-09)