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:
The default level of protection is complete protection, in which files
are encrypted and inaccessible when the device is locked. You can
programmatically set the level of protection for files created by your
app [...]
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:
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
@YES, NSMigratePersistentStoresAutomaticallyOption,
@YES, NSInferMappingModelAutomaticallyOption,
NSFileProtectionComplete, NSPersistentStoreFileProtectionKey, // <-- HERE
nil];
...
__persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error]) {
...
}
NSFileProtectionComplete
means
The file is stored in an encrypted format on disk and cannot be read
from or written to while the device is locked or booting.
You could also use NSFileProtectionCompleteUnlessOpen
, see the Xcode Quick Help for differences.