Waits for any scheduled file access to complete, then invokes the passed-in block.
- macOS 10.7+
A block that performs file access.
Given a block that will perform file access, this method waits for any file access scheduled by previous invocations of this method or
perform to complete, then invokes the passed-in block. When the block invocation returns, the method allows the next scheduled file access to to be performed, if any.
perform, this method’s primary use is to wait for asynchronous saving, but in contrast with that method it is only for the part of an asynchronous saving operation that actually touches the document’s file or values in memory that are relative to the document’s file.
In general, you should use this method or
perform around code that gets or sets values in memory that only make sense in the context of the document file’s current state. For example,
NSDocument itself consistently uses this mechanism when using the following methods and properties:
autosavedproperties, because you can’t reliably make decisions based on a file’s location, type, or modification date when it is being asynchronously moved, renamed, or changed at that moment.
Contents File URL
hasproperties, because you can’t reliably make decisions based on whether the document’s contents in memory have been saved to a file when it is being asynchronously saved at that moment.