PulseCanvas / app / mobile / MobileProject.swift
| 1 | import SwiftUI |
| 2 | import UniformTypeIdentifiers |
| 3 | |
| 4 | extension UTType { |
| 5 | static let pulseCanvasProject = UTType(exportedAs: "com.protomota.pulsecanvas.project", conformingTo: .json) |
| 6 | } |
| 7 | struct MobileProjectDocument: FileDocument { |
| 8 | static var readableContentTypes: [UTType] { [.pulseCanvasProject, .json] } |
| 9 | var data: Data |
| 10 | init(data: Data) { self.data = data } |
| 11 | init(configuration: ReadConfiguration) throws { |
| 12 | guard let data = configuration.file.regularFileContents, data.count < 8_000_000 else { throw CocoaError(.fileReadCorruptFile) } |
| 13 | self.data = data |
| 14 | } |
| 15 | func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper { FileWrapper(regularFileWithContents: data) } |
| 16 | } |