1

I want to copy set of files from project resource folder to the app document folder automatically at the time of app first launch. Can I do this. Do I need to do it through the code.

4

1 回答 1

6
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];

}

在应用程序中确实完成了带有选项的启动

于 2012-06-29T10:24:36.090 回答