So I am working on a app which stores user information with CoreData
framework locally. The information can be sensitive, so I am thinking how to protect the information stored to the data base. In Xcode dashboard, under the capabilities tab, I found this Data Protection switch:
Anyone knows how this works? If I turn on the switch will Xcode encode my CoreData
files automatically? Or how to implement this protection on my CoreData
files?
Appreciate your time and patient. Thank you!
You found the right spot, you have to turn on the Data Protection switch in your target's capabilities pane to signal that you want to use data protection. According to Apple's documentation, this should suffice:
It states you can set the level of protection programmatically. If you want to do that (I still do that, to be save ;), you should use the appropriate option when creating the persistentStoreCoordinator:
NSFileProtectionComplete
meansYou could also use
NSFileProtectionCompleteUnlessOpen
, see the Xcode Quick Help for differences.