【发布时间】:2013-08-06 20:20:12
【问题描述】:
我可以通过以下方式进行相反的操作:但无法复制到应用程序包。
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];
【问题讨论】:
-
我很确定不允许写入捆绑目录。它不是沙盒的一部分。
-
一个应用包被签名,添加一个文件会破坏签名
-
应用程序的包目录是只读的。
标签: ios appstore-sandbox