Initializer

init(contentsOfFile:)

Creates an attachment from the contents of an existing file on disk.

Declaration

convenience init(contentsOfFile url: URL)

Parameters

url

The file URL from which data should be read to create the new attachment.

Discussion

The attachment's name property is the file name of the provided url. The attachment's uniformTypeIdentifier value is inferred from the file's extension. A default UTI of "public.data" is used for files without an extension.

See Also

Creating Attachments from Files and Folders

init(contentsOfFile: URL, uniformTypeIdentifier: String)

Creates an attachment from the contents of an existing file on disk, with a custom UTI.

init(compressedContentsOfDirectory: URL)

Creates an attachment containing a zipped archive of an existing directory on disk.