Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. func save_to_file(_ textView: UITextView)
  2. {
  3. let file = "file.txt"
  4. let text = textView.text
  5. if let dir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first {
  6.  
  7. let fileURL = dir.appendingPathComponent(file)
  8.  
  9. //writing
  10. do {
  11. try text.write(to: fileURL, atomically: false, encoding: .utf8)
  12. }
  13. catch {/* error handling here */}
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement