我已将一个 javascript 文件添加到我的应用程序资源包中,我需要将其移动到文档目录,但当我启动其路径进行复制时,它返回 null。
代码:
NSString *jsPath = [[NSBundle mainBundle] pathForResource:@"jsFile" ofType:@"js"];
NSString *copyPath = [path stringByAppendingString:@"/jsFile.js"]; //path is the documents dir
NSLog(@"%@", jsPath); //Output of this is (null)
if ([[NSFileManager defaultManager] fileExistsAtPath:jsPath]) //returns false
[[NSFileManager defaultManager] copyItemAtPath:jsPath toPath:copyPath error:nil];
有人以前遇到过这种情况吗?
最佳答案
检查您的 js 文件是否已编译,而不是复制到 bundle 中。您需要在“构建阶段”下查看当前目标...
关于javascript - iPhone/iOS - [NSBundle mainBundle] pathForResources 无法查看 Javascript 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9453929/