Last active
October 23, 2021 01:21
-
-
Save acwright/17f65e965d03da153fe67dcc1143213b to your computer and use it in GitHub Desktop.
fileImporter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.fileImporter( | |
isPresented: $isImporting, | |
allowedContentTypes: [.plainText], | |
allowsMultipleSelection: false | |
) { result in | |
do { | |
guard let selectedFile: URL = try result.get().first else { return } | |
guard let message = String(data: try Data(contentsOf: selectedFile), encoding: .utf8) else { return } | |
document.message = message | |
} catch { | |
// Handle failure. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment