Locating Directories as Paths
The following example illustrates how you can use the NSSearchPathForDirectoriesInDomains
function to find the current user’s Documents directory:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); |
if ([paths count] > 0) { |
NSString *userDocumentsPath = [paths objectAtIndex:0]; |
// Implementation continues... |
NSSearchPathForDirectoriesInDomains
simply returns the path of the appropriate directory, it does not guarantee that the directory exists. If you want to perform operations such as writing to the directory, you may have to create it first.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.