いくつかの質問といくつかの問題があります。
私がしたいこと:
MyApp.app/Assets/Debug/debug.xml 内のファイルの名前を MyApp.app/Assets/Debug/debug_2.xml に変更します
1. NSString *filePath = [[NSBundle mainBundle] pathForResource:@"debug" ofType:"xml" inDirectory:@"Assets"]; returns (null)
2. NSString *filePath = [[NSBundle mainBundle] pathForResource:@"debug" ofType:"xml" inDirectory:@"Debug"]; returns (null)
3. NSString *filePath = [[NSBundle mainBundle] pathForResource:@"debug" ofType:"xml"]; WORKS(it finds the file EVEN if its not in the .app its in .app/Assets/Debug.xml)
しかし:
if ([fm fileExistsAtPath:path]) {
NSString *newPath = [[NSBundle mainBundle] pathForResource:@"newfile" ofType:@"xml"];
[fm copyItemAtPath:path toPath:newPath error:NULL];
} else {
NSLog(@"File does not exists");
}
コードは常にこのエラーをスローします:
-[NSFileManager copyItemAtPath:toPath:error:]: destination path is nil'
もちろん、ファイルは存在しませんが、ファイルパスと同じパスです..別の名前が付いているだけです:)
.app フォルダー内のファイルの名前を同じパスで別の名前に変更したい。
どんな助けでも大歓迎です!
また、上記の例 1 と 2 では、inDirectory パラメータを使用すると null パスが返されるのはなぜですか? ビルドリソースなどにフォルダーを追加しました..すべてをテストしました
ありがとう