开发者

Confused about phonegap and IOS, need to get file from 'www' path from 'Plugin' folder

I am using phonegap for IOS. I created a Plugin to unzip files. But now I am trying to test it but its unable to get the correct file path I'm assuming. Right now here is the snippet of where I cal the unzip method, from my ZipArchive plugin class:

NSLog(@"Trying to unzip file");
if([ za UnzipOpenFile:@"../www/data/test.zip"]){
  NSLog(@"UnzipOpenFile passed");
}

The structure of the phonegap is something like this

- ProjectName
  - www
    - data
      - test.zip
  - Plugin
    - ZipArchive.m //where the above snippet lies

I am t开发者_如何学编程hinking I can't use relative path like that because in the end product, when compiled and testing on simulator, the path will probably be different. How would I access the www/data folder from ZipArchive.m? Thanks.


You should be able to get a path to things in the www folder with:

[[[NSBundle mainBundle] resourcePath]
 stringByAppendingPathComponent:@"www/data/test.zip"];

Where are you planing to unzip to? Im quite sure the resource path is read-only when running on a real device. But the documents path and a tmp folder is writeable.

http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/RuntimeEnvironment/RuntimeEnvironment.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜