Graphics Programs Reference
In-Depth Information
{
NSArray *documentDirectories =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
// Get one and only document directory from that list
NSString *documentDirectory = [documentDirectories objectAtIndex:0];
return [documentDirectory stringByAppendingPathComponent:@"items.archive"];
}
You can build to check for syntax errors.
The function NSSearchPathForDirectoriesInDomains searches the filesystem
for a path that meets the criteria given by the arguments. On iOS, the last two arguments
are always the same. (This function is borrowed from Mac OS X, where there are signific-
antly more options.) The first argument is a constant that specifies the directory in the
sandbox you want the path to. For example, searching for NSCachesDirectory will
return the Caches directory in the application's sandbox.
You can search the documentation for one of the constants you already know - like
NSDocumentDirectory - to locate the other options. Remember that these constants
are shared by iOS and Mac OS X, so not all of them will work on iOS.
The return value of NSSearchPathForDirectoriesInDomains is an array of
strings. It is an array of strings because, on Mac OS X, there may be multiple paths that
meet the search criteria. On iOS, however, there will only be one (if the directory you
searched for is an appropriate sandbox directory). Therefore, the name of the archive file
is appended to the first and only path in the array. This will be where BNRItem s live.
Search WWH ::




Custom Search