Instance Method

performSynchronousFileAccessUsingBlock:

Waits for any scheduled file access to complete, then invokes the passed-in block.

Declaration

- (void)performSynchronousFileAccessUsingBlock:(void (^)(void))block;

Parameters

block

A block that performs file access.

Discussion

Given a block that will perform file access, this method waits for any file access scheduled by previous invocations of this method or performAsynchronousFileAccessUsingBlock: 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.

Like performActivityWithSynchronousWaiting:usingBlock:, 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 performAsynchronousFileAccessUsingBlock: 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:

See Also

Serialization

continueActivityUsingBlock:

Invokes the passed-in block to avoid a deadlock if performActivityWithSynchronousWaiting:usingBlock: is being invoked recursively.

continueAsynchronousWorkOnMainThreadUsingBlock:

Invokes the passed-in block on the main thread.

performActivityWithSynchronousWaiting:usingBlock:

Waits for any work scheduled by previous invocations of this method to complete, then invokes the passed-in block.

performAsynchronousFileAccessUsingBlock:

Waits for any scheduled file access to complete but without blocking the main thread, then invokes the passed-in block.