The default Core Data for iOS template stores data in an .sqlite
file in the NSDocumentDirectory
. The file is therefor visible if the iDevice is connected to iTunes and file sharing is enabled.
I would like to change the directory to something that is not visible to the user and I would choose the NSApplicationSupportDirectory
. Is this the correct directory? What do other developers use?
Core Data is an object graph and persistence framework provided by Apple in the macOS and iOS operating systems. It was introduced in Mac OS X 10.4 Tiger and iOS with iPhone SDK 3.0. It allows data organized by the relational entity–attribute model to be serialized into XML, binary, or SQLite stores.
Use Core Data to save your application's permanent data for offline use, to cache temporary data, and to add undo functionality to your app on a single device. To sync data across multiple devices in a single iCloud account, Core Data automatically mirrors your schema to a CloudKit container.
Core Data is not a database. Core Data is a framework for managing an object graph. An object graph is nothing more than a collection of interconnected objects. The framework excels at managing complex object graphs.
The best place (on the iPhone) is the Library folder, as described here:
How can I get a writable path on the iPhone?
That directory is meant for things like databases that you do not want the user to be able to see through sharing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With