it is possible. I made a small helper method that creates a path inaccessible via itunes. The database will be stored in the library directory, which is included in itunes backups.
- (NSString *)applicationPrivateDocumentsDirectory { static NSString *path; if (!path) { NSString *libraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) lastObject]; path = [libraryPath stringByAppendingPathComponent:@"Private Documents"]; BOOL isDirectory; if (![[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDirectory]) { NSError *error = nil; if (![[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error]) { NSLog(@"Can't create directory %@ [%@]", path, error); abort();
and then you replace
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"SomeApp.sqlite"];
in the method - (NSPersistentStoreCoordinator *)persistentStoreCoordinator using:
NSURL *storeURL = [NSURL fileURLWithPath:[[self applicationPrivateDocumentsDirectory] stringByAppendingPathComponent:@"SomeApp.sqlite"]];
Matthias Bauch Mar 09 2018-11-11T00: 00Z
source share