How to access special directory on the iphone device

Use NSSearchPathForDirectoriesInDomains(). First argument “NSDocumentDirecotry” is the key to specify special directory, in this case Document directory under the application. The method returns absolute path expression.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                               NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSLog(@"NSDocumentDirectory is %@", documentsDirectory);

Following is the list of the special directory key and result. Some keys are defined in the header file but actually they return nothing.

NSApplicationDirectory: /var/mobile/Applications/{APPID}/Applications
NSDemoApplicationDirectory: /var/mobile/Applications/{APPID}/Applications/Demos
NSDeveloperApplicationDirectory: /var/mobile/Applications/{APPID}/Developer/Applications
NSAdminApplicationDirectory: /var/mobile/Applications{APPID}/Applications/Utilities
NSLibraryDirectory: /var/mobile/Applications/{APPID}/Library
NSDeveloperDirectory: /var/mobile/Applications/{APPID}/Developer
NSUserDirectory: Not found
NSDocumentationDirectory: /var/mobile/Applications{APPID}/Library/Documentation
NSDocumentDirectory: /var/mobile/Applications{APPID}/Documents
NSCoreServiceDirectory: Not found
NSDesktopDirectory: /var/mobile/Applications/{APPID}/Desktop
NSCachesDirectory: /var/mobile/Applications/{APPID}/Library/Caches
NSApplicationSupportDirectory: /var/mobile/Applications/{APPID}/Library/Application Support
NSDownloadsDirectory: /var/mobile/Applications/{APPID}/Downloads
NSAllApplicationsDirectory: /var/mobile/Applications/{APPID}/Applications
NSAllLibrariesDirectory: /var/mobile/Applications{APPID}/Library

No comments yet.

Leave a Reply