Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

NSFileCoordinatorMBS class

Type Topic Plugin Version macOS Windows Linux Console & Web iOS
class iCloud MBS MacCloud Plugin 11.2 Yes No No Yes, macOS only No
Function: The class for file coordinating.
Notes: Please also check the documentation from Apple for the NSFileCoordinator class.

Feedback, Comments & Corrections

Reading flag constants.

Constant Value Description
NSFileCoordinatorReadingResolvesSymbolicLink 2 Whether reading of an item that might be a symbolic link file causes the resolution of the link if it is. This affects the URL passed to the block passed to an invocation of one of the coordinateReadingItemAtURL... methods. This is not a valid option to use with prepareForReadingItemsAtURLs.
NSFileCoordinatorReadingWithoutChanges 1 Whether reading does _not_ trigger sending of savePresentedItemChangesWithCompletionHandler to certain NSFilePresenters in the system and waiting for those NSFilePresenters to respond. The default behavior during coordinated reading is to send savePresentedItemChangesWithCompletionHandler to NSFilePresenters.

Writing flag constants.

Constant Value Description
NSFileCoordinatorWritingForDeleting 1 Whether the writing to be done is actually the deletion of the item. This affects how the writing waits for previously scheduled coordinated reading and writing, how the writing causes subsequently scheduled reading and writing to wait, and what NSFilePresenter messaging is done. See the comments in the Single File Coordination section below. This option is how you trigger sending of accommodatePresentedItemDeletionWithCompletionHandler or accommodatePresentedSubitemDeletionAtURL messages to NSFilePresenters.

For example, Finder uses this when it's emptying the trash to give NSFilePresenters a chance to close documents before their files disappear, or would disappear if the files weren't still open.
NSFileCoordinatorWritingForMerging 4 Whether coordinated writing triggers sending of savePresentedItemChangesWithCompletionHandler to certain NSFilePresenters in the system and waiting for those NSFilePresenters to respond.
NSFileCoordinatorWritingForMoving 2 Whether the writing to be done is actually the moving or renaming of the item. This affects how the writing waits for previously scheduled coordinated reading and writing, how the writing causes subsequently scheduled reading and writing to wait, and what NSFilePresenter messaging is done. See the comments in the Single File Coordination section below. This option has no effect when what's being moved is a plain file so you can use it in code that moves file system items without checking whether the items are files or directories. Any such check would invite a race condition anyway.

For example, Finder uses this when it's moving items that the user has dragged and dropped so as not to yank files contained by moved folders out from underneath applications that are reading or writing those files.
NSFileCoordinatorWritingForReplacing 8 Whether the writing to be done is actually the replacement of the item with a different item. It causes the same behavior as NSFileCoordinatorWritingForDeleting except that when the item being written to is renamed or moved while the writer is being made to wait the item is considered to have been a different item, so the writer is not passed an updated URL to reflect the renaming or moving. Use this when the moving or creation of an item will replace any item that gets in its way. To avoid a race condition use it regardless of whether there is actually an item in the way before the writing begins. Don't use this when simply updating the contents of a file, even if the way you do that is writing the contents to another file and renaming it into place. This is not a valid option to use with prepareForReadingItemsAtURLs.

For example, NSDocument uses this for NSSaveAsOperation and NSSaveToOperation to announce that it is possibly overwriting an item with a brand new file or file package. This gives any NSFilePresenter of the overwritten item, including perhaps a different instance of NSDocument, perhaps in the same application, a chance to close itself before the item is overwritten.

For another example, the most accurate and safe way to coordinate a move is to invoke coordinateWritingItemAtURL using the NSFileCoordinatorWritingForMoving option with the source URL and NSFileCoordinatorWritingForReplacing with the destination URL.

This class has no sub classes.


The items on this page are in the following plugins: MBS MacCloud Plugin.


NSExpressionMBS   -   NSFileHandleMBS




Links
MBS Xojo Chart Plugins