< Previous PageNext Page > Hide TOC

Deprecated NSDocumentController Methods

A method identified as deprecated has been superseded and may become unsupported in the future.

Deprecated in Mac OS X v10.4

documentForFileName:

Returns the document object for the file in which the document data is stored. (Deprecated in Mac OS X v10.4. Use documentForURL: instead.)

- (id)documentForFileName:(NSString *)fileName

Discussion

The fileName argument is a fully qualified path in the file system. Returns nil if no document can be found.

Availability
See Also
Related Sample Code
Declared In
NSDocumentController.h

fileNamesFromRunningOpenPanel

Returns a selection of files chosen by the user in the Open panel. (Deprecated in Mac OS X v10.4. Use URLsFromRunningOpenPanel instead.)

- (NSArray *)fileNamesFromRunningOpenPanel

Discussion

Each file in the returned NSArray is a fully qualified path to the file’s location in the file system. This method is invoked by openDocument:, and it invokes runModalOpenPanel:forTypes: after initializing the Open panel (which includes getting the starting directory with currentDirectory). Returns nil if the user cancels the Open panel or makes no selection.

Availability
Declared In
NSDocumentController.h

makeDocumentWithContentsOfFile:ofType:

Creates and returns a document object of a given document type from the contents of a file. (Deprecated in Mac OS X v10.4. Use makeDocumentWithContentsOfURL:ofType:error: instead.)

- (id)makeDocumentWithContentsOfFile:(NSString *)fileName ofType:(NSString *)docType

Discussion

Creates and returns an NSDocument object for document type docType from the contents of the file fileName, which must be a fully qualified path. The returned object is not retained. Returns nil if the NSDocument subclass for docType couldn’t be determined or if the object couldn’t be created. This method invokes the NSDocument method initWithContentsOfFile:ofType: and is invoked by openDocumentWithContentsOfFile:display:.

Availability
See Also
Related Sample Code
Declared In
NSDocumentController.h

makeDocumentWithContentsOfURL:ofType:

Creates and returns a ocument object for the given document type from the contents of a given URL. (Deprecated in Mac OS X v10.4. Use makeDocumentWithContentsOfURL:ofType:error: instead.)

- (id)makeDocumentWithContentsOfURL:(NSURL *)aURL ofType:(NSString *)docType

Discussion

Creates and returns an NSDocument object for document type docType from the contents of aURL. The returned object is not retained. Returns nil if the NSDocument subclass for docType couldn’t be determined or if the object couldn’t be created. This method invokes the NSDocument method initWithContentsOfURL:ofType: and is invoked by openDocumentWithContentsOfURL:display:.

Availability
See Also
Related Sample Code
Declared In
NSDocumentController.h

makeUntitledDocumentOfType:

Creates and returns a document object for document type. (Deprecated in Mac OS X v10.4. Use makeUntitledDocumentOfType:error: instead.)

- (id)makeUntitledDocumentOfType:(NSString *)type

Discussion

Creates and returns an NSDocument object for document type type. The returned object is not retained. Returns nil if the NSDocument subclass for type couldn’t be determined or if the object couldn’t be created. This method invokes the NSDocument init method and is invoked by openUntitledDocumentOfType:display:.

Availability
See Also
Declared In
NSDocumentController.h

openDocumentWithContentsOfFile:display:

Returns a document object created from the contents of a given file and optionally displays it. (Deprecated in Mac OS X v10.4. Use openDocumentWithContentsOfURL:display:error: instead.)

- (id)openDocumentWithContentsOfFile:(NSString *)fileName display:(BOOL)flag

Discussion

Returns an NSDocument object created from the contents of the file fileName (an absolute path) and displays it if flag is YES. 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 YES, the document is not displayed if shouldCreateUI returns NO. This method invokes makeDocumentWithContentsOfFile:ofType: to obtain the created NSDocument object. If you override this method, your implementation should be prepared to handle either YES or NO.

To handle an Open Documents Apple event, the Application Kit’s built-in Apple event handling automatically invokes this method with the path to the file to open and a display argument.

Invoked with a display argument of YES instead of NO when a Print Documents Apple event is handled. This may have been handled differently in versions of Mac OS X prior to version 10.3.

Availability
See Also
Related Sample Code
Declared In
NSDocumentController.h

openDocumentWithContentsOfURL:display:

Returns a document object created from the contents of a given URL and optionally displays it. (Deprecated in Mac OS X v10.4. Use openDocumentWithContentsOfURL:display:error: instead.)

- (id)openDocumentWithContentsOfURL:(NSURL *)aURL display:(BOOL)flag

Discussion

Returns an NSDocument object created from the contents of aURL and displays it if flag is YES. 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 aURL does not point to a valid location or because there is no NSDocument subclass for the document type. Even if flag is YES, the document is not displayed if shouldCreateUI returns NO. This method invokes makeDocumentWithContentsOfURL:ofType: to obtain the created NSDocument object.

Availability
See Also
Declared In
NSDocumentController.h

openUntitledDocumentOfType:display:

Returns a document object instantiated from the subclass of the given document type and optionally displays it. (Deprecated in Mac OS X v10.4. Use openUntitledDocumentAndDisplay:error: with defaultType instead.)

- (id)openUntitledDocumentOfType:(NSString *)docType display:(BOOL)display

Discussion

Returns an NSDocument object instantiated from the NSDocument subclass required by document type docType and displays it if flag is YES. 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 no NSDocument subclass could be found for docType. Even if flag is YES, the document is not displayed if shouldCreateUI returns NO. This method invokes makeUntitledDocumentOfType: to obtain the created NSDocument object.

Availability
See Also
Declared In
NSDocumentController.h

setShouldCreateUI:

Sets whether the window controllers of a document should be created when the document is created. (Deprecated in Mac OS X v10.4. Use the display parameter of openUntitledDocumentAndDisplay:error: or openDocumentWithContentsOfURL:display:error: instead.)

- (void)setShouldCreateUI:(BOOL)flag

Discussion

Sets whether the window controllers (NSWindowController instances) of a document should be created when the document is created. When a window controller is created, it loads the nib file containing the window it manages. Often flag is set to NO for scripting or searching operations involving the document’s data.

Availability
See Also
Declared In
NSDocumentController.h

shouldCreateUI

Returns a Boolean value that indicates whether the window controllers of a document should be created when the document is created. (Deprecated in Mac OS X v10.4. Use the display parameter of openUntitledDocumentAndDisplay:error: or openDocumentWithContentsOfURL:display:error: instead.)

- (BOOL)shouldCreateUI

Return Value

A Boolean value that indicates whether the window controllers (NSWindowController instances) of a document should be created when the document is created.

Availability
See Also
Declared In
NSDocumentController.h

Deprecated in Mac OS X v10.5

fileExtensionsFromType:

Returns the allowable file extensions for the given document type. (Deprecated in Mac OS X v10.5.)

- (NSArray *)fileExtensionsFromType:(NSString *)documentTypeName

Parameters
documentTypeName

The name of a document type, specified by CFBundleTypeName in the application’s Info.plist file.

Return Value

The allowable file extensions (as NSString objects) for documentTypeName.

Discussion

Type extensions are specified by the CFBundleTypeExtensions array for the given type in the Info.plist file.

The first string in the returned array is typically the most common extension. The array may also contain encoded HFS file types as will as filename extensions.

Availability
See Also
Declared In
NSDocumentController.h

typeFromFileExtension:

Returns the document type associated with files having extension fileExtensionOrHFSFileType. (Deprecated in Mac OS X v10.5.)

- (NSString *)typeFromFileExtension:(NSString *)fileExtensionOrHFSFileType

Discussion

fileExtensionOrHFSFileType may also be an encoded HFS file type, as well as a filename extension.

Availability
See Also
Declared In
NSDocumentController.h

< Previous PageNext Page > Hide TOC


© 2008 Apple Inc. All Rights Reserved. (Last updated: 2008-10-15)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.