Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can filter out the files that you make visible to the app, but not what is visible to iTunes FS.</p> <p>When I added my iTunes File Sharing support to my app, I wrote code to silently move the DB file to a new directory that would not be visible to iTFS. The code below moves the sqlite DB file from the Documents directory to the Application Support directory which is not visible to iTFS.</p> <pre><code>- (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if (persistentStoreCoordinator != nil) { return persistentStoreCoordinator; } // // Move th DB file to a different directory because of the file sharing // feature. // NSString *oldDBFile = [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"db.sqlite"]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); NSString *newDBFile; NSString *dbpath; NSFileManager *fileMgr = [NSFileManager defaultManager]; NSError *error; NSURL *storeUrl; BOOL dir; dbpath = ([paths count] &gt; 0 ? [paths objectAtIndex:0] : @""); newDBFile = [dbpath stringByAppendingPathComponent:@"db.sqlite"]; if ([dbpath length] &amp;&amp; [fileMgr fileExistsAtPath:dbpath isDirectory:&amp;dir] == NO) { if ([fileMgr createDirectoryAtPath:dbpath withIntermediateDirectories:YES attributes:nil error:&amp;error] == NO) { NSLog(@"Cannot create %@: %@ %@", dbpath, [error localizedDescription], [error userInfo]); } } if ([fileMgr fileExistsAtPath:oldDBFile]) { if ([fileMgr moveItemAtPath:oldDBFile toPath:newDBFile error:&amp;error] != YES) { NSLog(@"Error moving DB: %@: %@", [error localizedDescription], [error userInfo]); storeUrl = [NSURL fileURLWithPath:oldDBFile]; } else { storeUrl = [NSURL fileURLWithPath:newDBFile]; } } else { storeUrl = [NSURL fileURLWithPath:newDBFile]; } NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]]; if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&amp;error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); // Handle the error. } return persistentStoreCoordinator; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload