我可以执行以下操作:但无法复制到应用程序包。
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];
答案 0 :(得分:6)
应用程序包是只读的。部署应用程序后无法修改它。
如果应用支持File Sharing,则可以通过iTunes访问应用文档文件夹中的文件。查看How to enable File Sharing for my app。