openDocumentWithContentsOfFile:display:
Returns a document object created from the contents of a given file and optionally displays it.
Declaration
- (id) openDocumentWithContentsOfFile:(NSString *) fileName display:(BOOL) display;Discussion
Returns an NSDocument object created from the contents of the file fileName (an absolute path) and displays it if flag is true. The returned object is not retained, but is added to the receiver’s list of managed documents. Returns nil if the object could not be created, typically because fileName does not point to a valid file or because there is no NSDocument subclass for the document type (as indicated by the file extension or HFS file type). Even if flag is true, the document is not displayed if shouldCreateUI returns false. This method calls makeDocumentWithContentsOfFile:ofType: to obtain the created NSDocument object. If you override this method, your implementation should be prepared to handle either true or false.
To handle an Open Documents Apple event, the Application Kit’s built-in Apple event handling automatically calls this method with the path to the file to open and a display argument.
Called with a display argument of true instead of false when a Print Documents Apple event is handled. This may have been handled differently in versions of macOS prior to version 10.3.
See Also
Deprecated Methods
documentForFileName:fileExtensionsFromType:fileNamesFromRunningOpenPanelmakeUntitledDocumentOfType:makeDocumentWithContentsOfURL:ofType:makeDocumentWithContentsOfFile:ofType:openDocumentWithContentsOfURL:display:openDocumentWithContentsOfURL:display:error:openUntitledDocumentOfType:display:reopenDocumentForURL:withContentsOfURL:error:setShouldCreateUI:shouldCreateUItypeFromFileExtension: