开发者

Where file downloads in iPhone?

If i will download file in iPhone from my custom Application, where it will save file and how to get list of downlo开发者_StackOverflowaded files before, if i will restart my app? Is there any named app storage or global storage like in Windows Phone 7?


It is your responsibility as a developer to save the file in the folder you like.

However you will only be only be able to save files and create folders in your application writeable path:

+ (NSString*) applicationWriteablePath                                                                                     
{                                                                                                                       
    NSArray *aPaths         = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);          
    NSString *aWritablePath = [aPaths objectAtIndex:0];                                                                 

    return aWritablePath;                                                                                               
}

Then, you can save files by using the NSFileManager. Please refer to the Apple Documentation to create your folders and save your files accordingly.


You can save user files in your app's Documents folder. You can construct an absolute path to your Documents folder with:

`NSString *docDir = [NSHomeDirectory() stringByAppendingPathComponent: @"Documents"];`

You will then need to enable iTunes File Sharing in your App's Info.plist.

To transfer files back and forth between Mac OS X or Windows, tether your device with its USB cable, launch iTunes, click on the icon of your device in the list on the left, click on the Apps tab in the pane on the right, scroll all the way to the bottom then click on your App's icon. The box to the right of your App's icon will list all the files in your Documents folder. There are buttons to transfer files back and forth.

This is how my App Warp Life deals with user documents, but I find it to be a huge PITA to have to use iTunes for this, and that it only works if my device is tethered - it won't work via wireless or BlueTooth. The UI for file transfer in iTunes is really clunky and hard-to-find for users who aren't incredibly clueful.

For that reason I am contemplating implementing some other way to transfer files. One way would be to run a small HTTP server within my App that would have just a single page listing the files, that could be downloaded by clicking their links, with a simple form for uploading files to the user's device.

Not only would that work wirelessly, but it would work with any operating system. I am quite certain that many of my target users run Linux and wouldn't be caught dead running Windows or Mac OS X if it weren' required that one use iTunes to configure one's device.


I never studied about it, but in the e-books provided by Apple is said that each app has its share of the file system.

so if you decide to download to a folder you, no matter where you download

check here if you want more information: Important Application Directories

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜