What is the URL to the Documents Directory in iOS

I keep forgetting this time and time again. There is more than one way to slice a cake:

Option 1

This is how the Apple Templates with Core Data do it. This method takes a file name and returns its URL in the Documents Directory:

Option 2

Here we make use of the foundation function NSHomeDirectory. This method takes a file name and returns its path in the Documents Directory:


If you don’t need to persist files you can make use of the NSTemporaryDirectory. Those files are not backed up and may be cleared by the OS when space is needed. It’s still good practice to delete them yourself if your app no longer needs them here.

About Jay Versluis

Jay is a medical miracle known as Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.