<!--
{
  "availability" : [
    "macOS: 10.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSDocument/unblockUserInteraction()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDocument(im)unblockUserInteraction"
  },
  "title" : "unblockUserInteraction()"
}
-->

# unblockUserInteraction()

Unblocks the main thread during asynchronous saving.

```
nonisolated func unblockUserInteraction()
```

## Discussion

If [`save(to:ofType:for:completionHandler:)`](/documentation/AppKit/NSDocument/save(to:ofType:for:completionHandler:)) is writing on a non-main thread because [`canAsynchronouslyWrite(to:ofType:for:)`](/documentation/AppKit/NSDocument/canAsynchronouslyWrite(to:ofType:for:)) has returned <doc://com.apple.documentation/documentation/Swift/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:)`](/documentation/AppKit/NSDocument/fileWrapper(ofType:)) invokes this when it has created the <doc://com.apple.documentation/documentation/Foundation/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:)`](/documentation/AppKit/NSDocument/writeSafely(to:ofType:for:)), [`write(to:ofType:for:originalContentsURL:)`](/documentation/AppKit/NSDocument/write(to:ofType:for:originalContentsURL:)), or [`write(to:ofType:)`](/documentation/AppKit/NSDocument/write(to:ofType:)) in such a way that the invocation of this method done by the [`write(to:ofType:)`](/documentation/AppKit/NSDocument/write(to:ofType:)) default implementation won’t happen during writing.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)