Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func save_to_file(_ textView: UITextView)
- {
- let file = "file.txt"
- let text = textView.text
- if let dir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first {
- let fileURL = dir.appendingPathComponent(file)
- //writing
- do {
- try text.write(to: fileURL, atomically: false, encoding: .utf8)
- }
- catch {/* error handling here */}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement