Τρίτη, 27 Μαρτίου 2012

NSSearchPathForDirectoriesInDomains


//Helper function to fetch the path to our to-do data stored on disk 
NSString *docPath()
{
    NSArray *pathList = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 
                                                            NSUserDomainMask,   
                                                            YES);
    return [[pathList objectAtIndex:0] stringByAppendingPathComponent:@"data.td"];
            
}

#:source: example from the Big Nerd Ranch Guide - Objective - C - Programming

and follows the documentation :) 

NSSearchPathForDirectoriesInDomains

Creates a list of directory search paths.
NSArray * NSSearchPathForDirectoriesInDomains (
   NSSearchPathDirectory directory,
   NSSearchPathDomainMask domainMask,
   BOOL expandTilde
);
Discussion
Creates a list of path strings for the specified directories in the specified domains. The list is in the order in which you should search the directories. IfexpandTilde is YES, tildes are expanded as described in stringByExpandingTildeInPath.
You should consider using the NSFileManager methods URLsForDirectory:inDomains: andURLForDirectory:inDomain:appropriateForURL:create:error:. which return URLs, which are the preferred format.
For more information on file system utilities, see “Creating Paths and Locating Directories

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου