blob: 5081fe3c2a72ea92dfc3bcb0f91a9dfd560ab9e1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import SwiftUI
import UniformTypeIdentifiers
struct JSONFileDocument: FileDocument {
static var readableContentTypes: [UTType] { [.json] }
var data: Data
init(_ data: Data) {
self.data = data
}
init(configuration: ReadConfiguration) throws {
guard let data = configuration.file.regularFileContents else {
throw CocoaError(.fileReadCorruptFile)
}
self.data = data
}
func fileWrapper(configuration _: WriteConfiguration) -> FileWrapper {
FileWrapper(regularFileWithContents: data)
}
}
|