User Defaults
Cocoa’s NSUserDefaults class can also be used as a crude form of command-line processing. NSUserDefaults automatically takes parameters of the form -parameter value and adds them to the defaults domain NSArgumentDomain. Every parameter must take a single argument. You cannot have optional arguments or parameters with no arguments when using this technique.
This is a volatile domain, so its values will not be saved to the user preferences. You probably do not want to use NSUserDefaults as the main configuration interface for command-line programs because it is inflexible, but it can be useful when you want to supply some optional command-line options. This is handy for supplying debugging or testing flags to a GUI program.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access