Contents

unblockUserInteraction()

Unblocks the main thread during asynchronous saving.

Declaration

nonisolated func unblockUserInteraction()

Discussion

If save(to:ofType:for:completionHandler:) is writing on a non-main thread because canAsynchronouslyWrite(to:ofType:for:) has returned true, but it is still blocking the main thread, this method unblocks the main thread. Otherwise, it does nothing. For example, the default implementation of fileWrapper(ofType:) invokes this when it has created the FileWrapper object to return. Assuming that the NSFileWrapper is not mutated by subsequent user actions, it is effectively a “snapshot” of the document’s contents, and once it is created it is safe to resume handling user events on the main thread, even though some of those user events might change the document’s contents before the NSFileWrapper object has been safely written. You can invoke this method to make asynchronous saving actually asynchronous if you’ve overridden writeSafely(to:ofType:for:), write(to:ofType:for:originalContentsURL:), or write(to:ofType:) in such a way that the invocation of this method done by the write(to:ofType:) default implementation won’t happen during writing.

See Also

Writing the Document’s Content