November 2013
Beginner
325 pages
9h 47m
English
Users expect files to be saved to specific directories. For example, my browser, by default, will download files to /Users/aaron/Downloads/. To make it easy for the programmer to do the right thing, Apple has created a function that will tell you the right directories for the appropriate purpose. For example, this piece of code will get you the path for the user’s Desktop directory:
// The function returns an array of paths
NSArray *desktops =
NSSearchPathForDirectoriesInDomains(NSDesktopDirectory, NSUserDomainMask, YES);
// But I know the user has exactly one desktop directory
NSString *desktopPath = desktops[0];
What other special directories are there? Here are the commonly used constants:
Read now
Unlock full access