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
canAsynchronouslyWrite(to:ofType:for:)write(to:ofType:)writeSafely(to:ofType:for:)fileWrapper(ofType:)data(ofType:)write(to:ofType:for:originalContentsURL:)save(to:ofType:for:delegate:didSave:contextInfo:)save(to:ofType:for:completionHandler:)fileAttributesToWrite(to:ofType:for:originalContentsURL:)NSDocument.SaveOperationType