FileWrapperDocumentReader
struct · iOS 27.0+ · SDK 27.1
struct FileWrapperDocumentReader<Snapshot>A document reader that deserializes a `FileWrapper` into a snapshot. This is the recommended reader for most documents. Provide a closure that converts a `FileWrapper` into your snapshot type, and `FileWrapperDocumentReader` handles file coordination and loading. func reader(configuration: sending ReadConfiguration) -> sending FileWrapperDocumentReader<String> { FileWrapperDocumentReader(configuration) { fileWrapper in guard let data = fileWrapper.regularFileContents else { throw CocoaError(.fileReadCorruptFile) } return String(decoding: data, as: UTF8.self) } } For package documents, navigate the `FileWrapper` hierarchy: FileWrapperDocumentReader(configuration) { directory in let children = directory.fileWrappers ?? [:] guard let metadataData = children["metadata.json"]? .regularFileContents else { throw CocoaError(.fileReadCorruptFile) } return try JSONDecoder().decode( Metadata.self, from: metadataData ) } > Important: `FileWrapper` loads file contents on demand. A > child file may be gone by the time you call > `regularFileContents`. Always handle errors when reading > children of a package. The closure does not receive a `Subprogress`. To report progress during reads, use a custom ``DocumentReader`` instead.
Members (0)
This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.
Skipped declarations
1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
FileWrapperDocumentReader.read(from:progress:)
The iOS SDK compiler rejected this binding: instance method 'arg' requires that 'Subprogress' conform to 'Copyable'