Type Method

canConcurrentlyReadDocumentsOfType:

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

Declaration

+ (BOOL)canConcurrentlyReadDocumentsOfType:(NSString *)typeName;

Parameters

typeName

The string that identifies the document type.

Return Value

NO by default; subclasses can override to return YES, thereby causing documents of the specified type to be read concurrently.

Discussion

Your NSDocument subclass can implement this method to return YES to enable loading of documents concurrently, using background threads. When this facility is enabled in this way, initWithContentsOfURL:ofType:error: executes on a background thread when opening files via the Open panel or from the Finder. This allows concurrent reading of multiple documents and also allows the app to be responsive while reading a large document.

The default implementation of this method returns NO. A subclass override should return YES only for document types whose reading is thread-safe, as described in Multicore Considerations. You should disable undo registration during document reading, which is a good idea even in the absence of concurrency.

If you are checking the current Apple Event for a search string, you should not enable concurrent document opening, because code handling a document opening triggered by an Apple Event cannot get the current Apple Event. This happens because the event is suspended until all documents are read to enable correct reporting of success or error.

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.

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.

- fileNameExtensionForType:saveOperation:

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