I want to know whether I can access the directory where my application is installed. Also I want to create a sub directory in the same directory to store all the images I capture in my application. I further want to view the images using iPhone's default image viewer. Can this be done?
NSString *appFolderPath = [[NSBundle mainBundle] resourcePath];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSLog(@"App Directory is: %@", appFolderPath);
NSLog(@"Directory Contents:\n%@", [fileManager directoryContentsAtPath: appFolderPath]);
You can get the Document folder of the app
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
You can create Folder and files using NSFileManger. You can store files in document folder or even you can store it in temp folder.
If you want to access the app on the simulator, navigate to this directory:
~/Library/Application Support/iPhone Simulator/User/Applications
If you want to access the app on a device it gets a little trickier. First, plug your iOS device into iTunes and backup the phone (with encryption turned off). Then download this app: iPhone / iPod Touch Backup Extractor, find your bundle ID and click extract. The app will then get all the data for you to see. Sure it's not real time but does the job!
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