Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>With Foundation, you can call <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/func/NSHomeDirectory" rel="nofollow noreferrer">the <code>NSHomeDirectory</code> function</a> to get the absolute path to the user's home directory. You can then use <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/stringByAppendingPathComponent:" rel="nofollow noreferrer">the path-manipulation methods of NSString</a> or <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html#//apple_ref/occ/instm/NSURL/URLByAppendingPathComponent:" rel="nofollow noreferrer">of NSURL</a>, or <a href="http://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFURLRef/Reference/reference.html#//apple_ref/c/func/CFURLCreateCopyAppendingPathComponent" rel="nofollow noreferrer">the equivalent function for CFURL</a>, to tack a sub-path onto that.</p> <p>However, please don't put files into the top level of my Home folder unless I, as the user, tell you to.</p> <ul> <li>If you want to save a file at the user's request, run a <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSSavePanel_Class/" rel="nofollow noreferrer">save panel</a>, and then save it where the user told you to.</li> <li>If you want to save a preferences file, you probably should be using <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/" rel="nofollow noreferrer">NSUserDefaults</a> or <a href="http://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFPreferencesUtils/" rel="nofollow noreferrer">CFPreferences</a>, instead of handling plists yourself.</li> <li>If you have some other reason to save a user-specific file, it should generally go into either <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/func/NSTemporaryDirectory" rel="nofollow noreferrer">the chewable items folder</a>, <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/func/NSSearchPathForDirectoriesInDomains" rel="nofollow noreferrer">the Caches folder</a>, or the Preferences folder. The two functions that I linked to are the easiest ways to access those two of those three folders; the harder way, and the only one that works on all three, is <a href="http://developer.apple.com/legacy/mac/library/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html#//apple_ref/c/func/FSFindFolder" rel="nofollow noreferrer">the <code>FSFindFolder</code> function</a>. Unlike most of the Folder Manager, <code>FSFindFolder</code> is not deprecated and is available in 64-bit.</li> </ul> <hr> <h3>Updates from the year 2012</h3> <ul> <li>Nowadays, you should use URLs, not paths. <a href="http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFileManager/URLForDirectory:inDomain:appropriateForURL:create:error:" rel="nofollow noreferrer">NSFileManager has a method for getting a URL to a desired directory.</a></li> <li>Stapling paths (or file URLs) together does not work in a sandboxed application, because you don't have authorization to access the path you just made up. You need to get the path (or URL) from a system API, whether it's NSFileManager, NSSavePanel, or something else.</li> <li>For saving and restoring file references, use NSURL's security-scoped bookmarks feature.</li> <li>NSUserDefaults and CFPreferences work as expected in a sandbox.</li> <li>The Folder Manager is now fully deprecated as of 10.8.</li> <li>Polluting the user's Home folder is still bad manners.</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload