Instance Method

fileNameExtensionForType:saveOperation:

Returns a filename extension that can be appended to a base filename, for a specified file type and kind of save operation.

Declaration

- (NSString *)fileNameExtensionForType:(NSString *)typeName saveOperation:(NSSaveOperationType)saveOperation;

Parameters

typeName

The file type.

saveOperation

The kind of save operation.

Return Value

The filename extension.

Discussion

The default implementation of this method invokes preferredFilenameExtensionForType: on the shared workspace object if the type is a UTI or, if it is not, for backward binary compatibility with OS X v10.4 and earlier, invokes fileExtensionsFromType: on the shared document controller and chooses the first filename extension in the returned array.

You can override this method to customize the appending of extensions to filenames by NSDocument. Starting in OS X v10.5, it is invoked from only two places in AppKit:

  1. The autosaveDocumentWithDelegate:didAutosaveSelector:contextInfo: method uses this method when creating a new filename for the autosaved contents.

  2. The handleSaveScriptCommand: method uses this method when adding an extension to the filename specified by a script.

In all other cases, the name of any file being saved will have been fully specified by the user with the Save panel (whether they know it or not).

See Also

Managing File Types

fileType

The name of the document type, as specified in the app’s Info.plist file.

fileTypeFromLastRunSavePanel

The file type that was last selected in the Save panel.

+ isNativeType:

Returns a Boolean value indicating whether document data of the specified type is a native type—one the receiver can both read and write.

readableTypes

Returns the types of data the receiver can read natively and any types filterable to that native type.

+ canConcurrentlyReadDocumentsOfType:

Returns a Boolean value indicating whether the receiver reads multiple documents of the given type concurrently.

writableTypes

Returns the types of data the receiver can write natively and any types filterable to that native type.

- writableTypesForSaveOperation:

Returns the names of the types to which this document can be saved for a specified kind of save operation.