【问题标题】:Xcode path resources in Cordova structureCordova 结构中的 Xcode 路径资源
【发布时间】:2013-10-02 11:36:27
【问题描述】:
如何在 Xcode 中更改这一行
NSString *filePath = [[NSBundle mainBundle] pathForResource:(@"%@",[command.arguments objectAtIndex:0]) ofType:@"pdf"];
查看 PDF 的 Phonegap (cordova) 文件结构,例如:
~/Library/Caches
或
~/Docuemnts
【问题讨论】:
标签:
objective-c
xcode
cordova
【解决方案1】:
我没有给你一个明确的答案,但我相信cordova-plugin-file 插件是可以找到答案的地方。我对它的经验有限,但看起来你会寻找以下路径:
cordova.file.cacheDirectory = '~/Library/Caches'
cordova.file.documentsDirectory = '~/Documents'
从cordova 文档看来,您将尝试从窗口对象获取DirectoryEntry,然后使用DirectoryReader 迭代包含的文件。可能有搜索,但我对 API 的了解不够深入。
var bundleDocs = window.resolveLocalFileSystemURL(cordova.file.documentsDirectory);
var bundleDocsReader = bundleDocs.createReader();
bundleDocsReader.readEntries(
function success(files) { // iterate over files and do stuff },
function error(err) { // respond to error }
);
希望有帮助!
注意:DirectoryEntry 和 DirectoryReader 的直接 API 参考链接到 Cordova 3.0 文档,因为 Cordova 5.1 插件文档很糟糕。