3

I can do the reverse with the following: But cannot copy to the app bundle.

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,    NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];

// Destination path
    NSString *fileInDocumentsPath = [documentsPath stringByAppendingPathComponent:@"Passwords File.txt"];
// Origin path - used when file is in bundle
    NSString *fileInBundlePath = [[NSBundle mainBundle] pathForResource:@"Passwords File" ofType:@"txt"];

// File manager for copying File in Bundle to Sandbox
    NSError *error = nil;
    NSFileManager *fileManager = [NSFileManager defaultManager];
    [fileManager copyItemAtPath:fileInBundlePath toPath:fileInDocumentsPath error:&error];
rob mayoff
  • 375,296
  • 67
  • 796
  • 848

1 Answers1

7

The application bundle is read only. It cannot be modified after you deploy the app.

Files in your app's documents folder can be accessed via iTunes if the app supports File Sharing. Check out How to enable File Sharing for my app.

Community
  • 1
  • 1
Marcus Adams
  • 53,009
  • 9
  • 91
  • 143
  • That makes sense. What I am trying to accomplish is to get a backup of the file copied to my Mac. Is there a way to do this? – Ronald Bledsoe Aug 06 '13 at 20:46
  • @RonaldBledsoe, Files in your app's documents folder can be accessed via iTunes if the app supports [File Sharing](http://support.apple.com/kb/HT4094). Check out [How to enable File Sharing for my app](http://stackoverflow.com/questions/6029916/how-to-enable-file-sharing-for-my-app). – Marcus Adams Aug 06 '13 at 21:00