我已将一个 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];
以前有没有人遇到过这种情况?