init(for:source:)
Creates a button that creates new documents using data from pasteboard.
Declaration
nonisolated init<D>(for type: D.Type, source: NewDocumentButtonDataSource) where D : FileDocumentParameters
- type:
Type of documents to create from pasteboard data.
- source:
A source of data that fills the newly created document.
Discussion
struct NewTextDocumentFromPasteboardButton: View {
var body: some View {
NewDocumentButton(
for: TextDocument.self, source: .pasteboard
)
}
}
struct TextDocument: FileDocument { ... }