Prior to iOS 16, FileManager needed to be used to save text files to the document directory of your app. Although FileManager needs to be used for some tasks, such as getting the contents of a directory, moving, copying, deleting files, and so on, the ability to save a text file is now available in the String class.
Files are stored in the documents directory of your app, which is sandboxed. If you delete your app, then those files will be deleted with it. With this in mind, make sure you understand the implications of this, as you may need to work with FileManager to save documents in iCloud if you want to keep them safe for your user. We’ll cover this in a different tutorial.
[Read more…]