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?
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
The files in the application's document directory will be displayed on the itunes as like:
Please check the tutorial for details.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With