<!--
{
  "availability" : [
    "iOS: 4.1.0 -",
    "iPadOS: 4.1.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVAssetWriter/cancelWriting()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAssetWriter(im)cancelWriting"
  },
  "title" : "cancelWriting()"
}
-->

# cancelWriting()

Cancels the creation of the output file.

```
func cancelWriting()
```

## Discussion

If the asset writer is in [`AVAssetWriter.Status.failed`](/documentation/AVFoundation/AVAssetWriter/Status-swift.enum/failed) or [`AVAssetWriter.Status.completed`](/documentation/AVFoundation/AVAssetWriter/Status-swift.enum/completed) state, calling this method has no effect. Otherwise, invoking it blocks the calling thread until the asset writer finishes canceling the writing session.

If the asset writer created an output file during the writing process, calling this method deletes the file.

---

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)