@cwoloszynski, I'm having the exact issue you discussed and I can't quite understand how you fixed it. For the exported/imported type identifier "conforms to" did you finally use "com.apple.package"?
I want a directory structure that looks like:
<UserChosenName.pspkg>/. // directory package containing my document data and images
PhraseSet.dat // regular file with serialized data from snapshot
Images/ // subdirectory for images (populated directly from my app as needed)
Image0.png
Image1.png
....
I'm using the following class for the FileWrapper to encapsulate what I think I need to do. Can you see something I'm doing incorrectly?
var snapshot: Data
init(withSnapshot: Data) {
self.snapshot = withSnapshot
let sWrapper = FileWrapper(regularFileWithContents: snapshot)
let dWrapper = FileWrapper(directoryWithFileWrappers: [:])
super.init(directoryWithFileWrappers: ["PhraseSet.dat" : sWrapper,
"Images" : dWrapper ])
// TO BE DONE: create subdirectory for images. Writing of
// images is done outside of the ReferenceFileDocument
// functionality.
}
override func write(to url: URL,
options: FileWrapper.WritingOptions = [],
originalContentsURL: URL?) throws {
if let fileWrappers = fileWrappers {
for (_, wrapper) in fileWrappers {
try wrapper.write(to: url, options: options,
originalContentsURL: originalContentsURL)
}
}
}
required init?(coder inCoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: