file://localhost/var/mobile/Application/EAC0BC34-6A82-41CB-AE44-9CD8E7D880C8/Documents
I get an alert this is my path, but i am unable to find where this location is all about. I am using iOS 5.0 to deploy my Application in ma device.
Thanks
Try this:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [paths objectAtIndex:0];
Or as per your tag, maybe you're using Titanium? If so maybe this helps:
https://wiki.appcelerator.org/display/guides/Filesystem+Access+and+Storage - Ti.Filesystem.applicationDataDirectory
Related
I have found half a dozen answers about where the iPhone Simulator folder is. This does not display my iPad Applications though.
Does anyone know where the iPad Simulator folder location is or a way to get the location?
Direct to the directory containing all simulators:
Right Click on the "Finder" icon in your dock
Click on Go to Folder
~/Library/Developer/CoreSimulator/Devices/
Swift
Use this print statement:
print(NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).last)
Objective-C
You can find the exact location by using NSLog Print statement
NSLog(#"%#",[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);
Then follow the first set of instructions with your location.
Put this code in your viewDidLoad
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSLog(#"path-%#",documentsDirectory);
Then open finder in your mac. Press Command+Shift+G and input the "documentsDirectory" that was printed in console using NSLog. That will show your path for the app document directory.
The folder location has been changed, instead of going to iPhone Simulator you have to go to Core Simulator.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachesDirectory = [paths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:#"%#/%#", cachesDirectory, fileName];
if ([[NSFileManager defaultManager]fileExistsAtPath:filePath]) {
return filePath;
}
else {
return filePath;
}
This code will show how you can check the files stored in the cache and how you can find the folder location.
Print description for the cache directory to get the path.
I am having random error while reading saved photos from document directory in iPhone. I save photos taken from my app to document directory and then read it from there next time when user come back. However, after XCode 6 & base SDK change to 8.1, this document directory path keeps changing. So sometime I found photos and sometime not.
I read few posts online thats says that not Apple differentiate App from Data and that's why this issue coming up. Anyone has any thoughts on this? Any solution?
This is how I save file to document Directory
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [path firstObject];
NSString *filePath = [documentDirectory stringByAppendingPathComponent:#"key"];
[image writeToFile:path atomically:YES];
And this is how I read it:
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [path firstObject];
NSString *filePath = [documentDirectory stringByAppendingPathComponent:#"key"];
UIImage *cellImage = [[UIImage alloc] initWithContentsOfFile:filePath];
Go to Product - Scheme - Edit Scheme - Options - Working Directory and specify working directory
I have an app on the market, I would like to localize it to other languages, the process I would like to implement is:
User downloads the app
User selects language
language pack is downloaded to applications folder
my question is how to implement step #3 (and does it effect the app review process) using adobe air
Thanks
Download your bundle to Documents directory with name "Translations.bundle", then use this code
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths firstObject];
NSString *bundlePath = [documentsPath stringByAppendingPathComponent:#"Translations.bundle"];
NSBundle *translationsBundle = [NSBundle bundleWithPath:bundlePath];
NSString *message = NSLocalizedStringFromTableInBundle(#"Message", nil, translationsBundle, nil);
I'm working on an app,now i used openssh find and get access to my mac's file system,I can access every folder at my app.That dangerous for my computer,I want to know is there any way I can only get the shared folder at my app,instead every folder.Just like use mac to connect other people's share folder,only get the share folder.what should i do,and i'm thinking get the share folder path and use it as an argument,is that right?
You can use
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSSharedPublicDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:#"Playlist"];
if you want path of Documents directory replace first line by this
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
I have an app where I need to annotate a pdf. I have been using code from how to edit a PDF in objective-c? and it's great, except the file location part. I was getting the pdf from using
NSString *newFilePath = [[NSBundle mainBundle] pathForResource:#"Untitled_4" ofType:#"pdf"];
This was working in the Simulator, but will not work on my testing iPad.
I was getting this error:
CGDataConsumerCreateWithFilename: failed to open 'long boring file path' for writing: Operation not permitted.
I also played around with
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *newFilePath = [documentsDirectory stringByAppendingPathComponent:#"Untitled_4.pdf"];
I now understand that "You are not allowed to write to the application bundle." Thanks The operation couldn’t be completed. Operation not permitted
When I later try to open the new annotated pdf it does not open correctly.
Any help would be greatly appreciated. You guys rock!
Hopefully this will help everyone else who needs help with pdf annotations in iOS.
Answering my own question.
I ended up using
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *newFilePath = [documentsDirectory stringByAppendingPathComponent:#"Untitled_4.pdf"];
then drawing everything.
The problem was not there, it was getting the finished pdf later to show it. I needed to use that same code later.
Thanks for your help.
Hope anyone confused who finds this later will have their problem solved as well.