I’m engaged on a macOS Catalyst app and want to avoid wasting a file utilizing UIActivityViewController
. Nevertheless, the “Save” possibility doesn’t seem after I current the exercise view controller. The file is offered as a URL, and I’ve tried storing it each within the Paperwork listing and the momentary listing, however the challenge persists. Curiously, the “Save” possibility exhibits up appropriately when the app runs within the “Designed for iPad” mode on macOS Catalyst. Under is the code snippet I’m utilizing:
struct ActivityViewController: UIViewControllerRepresentable {
@Binding var activityItems: [Any]
var applicationActivities: [UIActivity]? = nil
@Surroundings(.presentationMode) var presentationMode
func makeUIViewController(context: UIViewControllerRepresentableContext) -> UIActivityViewController {
print("ActivityViewController.makeUIViewController() - activityItems=(activityItems)")
let controller = UIActivityViewController(activityItems: activityItems, applicationActivities: applicationActivities)
return controller
}
func updateUIViewController(_ uiViewController: UIActivityViewController, context: UIViewControllerRepresentableContext) {}
}
File URL:
func macOSEncryptFile(at fileURL: URL, password: String) throws -> URL {
let fileManager = FileManager.default
let fileData = strive Information(contentsOf: fileURL)
let encryptedData = RNCryptor.encrypt(knowledge: fileData, withPassword: password)
let originalFileNameWithExtension = fileURL.lastPathComponent
let tempDirectoryURL = fileManager.temporaryDirectory
let encryptedFileURL = tempDirectoryURL.appendingPathComponent(originalFileNameWithExtension).appendingPathExtension("crpt")
strive encryptedData.write(to: encryptedFileURL)
return encryptedFileURL
}