One Quickie


Finding things like ~/Library, and ~/Library/Application Services (Random->General)
NSSearchPathForDirectoriesInDomains is how you find the location of things like Library directories, or User directories, document directory, and the like (this is the NSSearchPathDirectory). The NSSearchPathDomainMask is what domains to find things in. For instance for a NSLibraryDirectory, a NSUserDomainMask will give you the path to ~/Library, NSSystemDomainMask will give you the path to /System/Library, and so on.

The directories inside of Library, like "Preferences" and "Application Support" are in English in the file system, and the Finder presents localized versions to the user. If you need ~/Library/Application Support/Borkware, you can construct it like

    NSMutableString *path;
    path = [[NSMutableString alloc] init];

    // find /User/user-name/Library
    NSArray *directories;
    directories = NSSearchPathForDirectoriesInDomains (NSLibraryDirectory,
                                                       NSUserDomainMask, YES);

    // if you had more than one user domain, you would walk directories and
    // work with each path
    [path appendString: [directories objectAtIndex: 0]];

    [path appendString: @"/Application Support"];
    [path appendString: @"/Borkware"];



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com