To get to my application documents folder, I use this code:
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
I want to access this folder, however:
~/Library/Mobile Documents
How can i easily access this as a path value? Can I do this in a similar way?
The benefit of using the constants to access system provided directories is that if Apple decide to change the structure, your application will still work. Hardcoding in something like
~/Library/Mobile Documentsis brittle.However, you can access the Library directory with the same
NSSearchPathForDirectoriesInDomainwith theNSLibraryDirectoryconstant. Then, you should just append theMobile Documentsdirectory path.Looking at the constant values in http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Constants/Reference/reference.html#//apple_ref/doc/c_ref/NSSearchPathDirectory, it appears there is no specific constant for the
Mobile Documentsdirectory, so the hardcoding approach might be your only option.