NSUserDomainMask


#1

NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

I know that NSDocumentDirectory has the path to Documents location, but what does NSUerDomainMask means? what other substitute are there to take the place of NSUserDomainMask, what does the YES do?


#2

This function was originally written for Cocoa (for Mac) development, and was carried over to iOS.

On the Mac, there are two searchable domains: the NSUserDomainMask (that is, search for directories within the user’s home folder) and NSSystemDomainMask (search for folders in the system folders). On iOS, there is only NSUserDomainMask.

The third argument is the answer to the question “Should tildes (~) be expanded in file paths?”. An example on the Mac would expand “~/Documents/” to “/Users/mikey/Documents”. On iOS, we /always/ want tildes to be expanded in file paths, so we always pass YES here.


#3

WHY AREN"T THIS EXPLANATION COVERED IN THE BOOK!!! thanks by the way


#4

You’re welcome!

The short answer is that a deep discussion of NSSearchPathsForDirectoriesInDomains() isn’t important for this chapter; the chapter is meant to give a peek into what iOS development is like, not to teach all of the different functions and methods you need in order to write iOS apps. There are other books for that. It’s not important to know yet what the arguments to that function are for- any iOS or Mac development book that you read after this one will thoroughly cover how to get paths to files on disk.