2013-09-26 167 views
2

我怎么能在Xcode中此行更改Xcode的路径资源

NSString *filePath = [[NSBundle mainBundle] pathForResource:(@"%@",[command.arguments objectAtIndex:0]) ofType:@"pdf"]; 

中的PhoneGap(科尔多瓦)的文件结构,以查找PDF,如:

~/Library/Caches 

~/Docuemnts 
+0

我相信答案在[cordova-plugin-file](https://github.com/apache/cordova-plugin-file)中的某处。我还没有使用它,但它看起来像你会寻找以下路径: –

回答

0

我没有给你明确的答案,但我相信cordova-plugin-file插件是答案的地方找到。我与它只有有限的经验,但它看起来像你要寻找以下路径:

  • cordova.file.cacheDirectory = '~/Library/Caches'
  • cordova.file.documentsDirectory = '~/Documents'

从科尔多瓦文档,它看起来像你会试图从窗口对象中获取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文档很糟糕。