<!--
{
  "availability" : [
    "iOS: 8.0.0 - 11.0.0",
    "iPadOS: 8.0.0 - 11.0.0",
    "visionOS: 1.0.0 - 1.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "FileProvider",
  "identifier" : "/documentation/FileProvider/NSFileProviderExtension/writePlaceholder(at:withMetadata:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "File Provider",
      "FileProvider"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileProviderExtension(cm)writePlaceholderAtURL:withMetadata:error:"
  },
  "title" : "writePlaceholder(at:withMetadata:)"
}
-->

# writePlaceholder(at:withMetadata:)

Writes a document placeholder with the provided metadata.

```
class func writePlaceholder(at placeholderURL: URL, withMetadata metadata: [URLResourceKey : Any]) throws
```

## Parameters

`placeholderURL`

The placeholder URL for the document. You can generate a placeholder URL from a document URL by calling [`placeholderURL(for:)`](/documentation/FileProvider/NSFileProviderExtension/placeholderURL(for:)).

`metadata`

The metadata for this document.

## Discussion

Call this method whenever you need to create a placeholder for a document. The metadata that you provide depends largely on the needs of your document picker’s user interface; however, the common options include file size, filename, and thumbnails.

You must not override this method.

> Handling Errors in Swift:
> In Swift, this method returns a nonoptional result and is marked with the `throws` keyword to indicate that it throws an error in cases of failure.
> 
> You call this method in a `try` expression and handle any errors in the `catch` clauses of a `do` statement, as described in [Error Handling](https://docs.swift.org/swift-book/LanguageGuide/ErrorHandling.html) in [The Swift Programming Language](https://docs.swift.org/swift-book/) and `About Imported Cocoa Error Parameters`.

---

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)