NSFileManagerを使用して、MyApp.app/Documentフォルダーにファイルを含むフォルダーを作成したいと思います。(MyAppは私のカスタムアプリです。)
そこで、IMG_0525.jpg(テスト用)をプロジェクトのフォルダにコピーしました。
次に、プロジェクトのフォルダーからMyApp.app/Documentフォルダーにコピーしようとします。
しかし、パス名を指定する方法がわかりません。(送信元と宛先のパス)
方法を教えていただけますか?
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self generateTableContents];
}
- (void)generateTableContents {
NSFileManager * fileManager = [NSFileManager defaultManager];
NSArray *appsDirectory = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentPath = [appsDirectory objectAtIndex:0];
NSLog(@"documentPath : %@", documentPath);
[fileManager changeCurrentDirectoryPath:documentPath];
[fileManager createDirectoryAtPath:@"user_List1" withIntermediateDirectories:YES attributes:nil error:nil];
// I'm trying to copy IMG_0525.jpg to MyApp.app/Document/user_List1 folder.
[fileManager copyItemAtPath:<#(NSString *)srcPath#> toPath:<#(NSString *)dstPath#> error:<#(NSError * *)error#>];
}