我有几个问题和一些问题:
我想做的事:
将 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 参数,为什么它会给我空路径?我在构建资源中添加了一个文件夹等..我测试了所有
谢谢