Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In iPhone, where does save a file downloaded from a iOS app

Tags:

ios

iphone

From my app, I can download a zip file from a server through NSURLConnection. While I'm downloading I'm writing to this into a file, so that it will save into documentsDirectory.

paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
documentsDirectory = [paths objectAtIndex:0];
currentDownload = [documentsDirectory stringByAppendingString:@"/Zipfile"];
NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:currentDownload];
[fileHandle seekToEndOfFile];
[fileHandle writeData:data];
[fileHandle closeFile];

This is the code I used for downloading and its working. If I run the app in simulator, I can see the downloaded file in MAC in the folder /Users/TECSOLiMac02/Library/Application Support/iPhone Simulator/6.0/Applications/9DECB1F4-C88D-4B62-BA1F-B9D5D4E421B9/Documents/Zipfile

Where can I see this downloaded file in iPhone/iPad?

like image 440
Noufal Kmc Avatar asked Dec 21 '12 09:12

Noufal Kmc


2 Answers

Every application is sandboxed in iPhone.Each application have it's on directory structure in device (like in simulator).

The path of document directory in mobile is something like:

/var/mobile/Applications/AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEFFFFFF/Documents/

The files in that directories cannot be accesses by any other applications. It can be accessed by the owner application itself. And can be accessed through code.

If you want to see the files in document directory you need to set the UIFileSharingEnabled key in the info.plist

info.plist

The files in the application's document directory will be displayed on the itunes as like:

File Sharing Please check the tutorial for details.

like image 171
Midhun MP Avatar answered Oct 10 '22 09:10

Midhun MP


If you want to see this files in iPhone/iPad you have to allow (set to YES) "Application supports iTunes file sharing" in the project Info.

like image 25
Ashbay Avatar answered Oct 10 '22 08:10

Ashbay