nat*_*ath 1 objective-c ipad ios
我想在应用程序首次启动时自动将项目资源文件夹中的一组文件复制到应用程序文档文件夹中。我可以这样做吗。我需要通过代码来做吗?
BOOL success;
NSError *error;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"Data.txt"];
success = [fileManager fileExistsAtPath:filePath];
if (!success) {
NSString *path = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"txt"];
success = [fileManager copyItemAtPath:path toPath:filePath error:&error];
}
Run Code Online (Sandbox Code Playgroud)
在应用程序中确实使用选项完成了启动
| 归档时间: |
|
| 查看次数: |
1956 次 |
| 最近记录: |