init(importing:contentType:)
Using the type’s Transferable conformance implementation, instantiates a value from the given file.
Declaration
init(importing file: URL, contentType: UTType?) async throwsParameters
- file:
A URL to a file on disk.
- contentType:
An optional content type for creating a value. If a value is not provided, the initializer tries to infer it from the file extension or its metadata. If the content type is still unknown, the framework calls the first transfer representation with this URL. If the item isn’t imported successfully, the framework calls the second representation and so on.
Discussion
The default implementation of this initializer is available to all types that conform to Transferable protocol.