r/macosprogramming • u/HKL0902 • Jan 05 '17
Where do apps generally save data for persistence?
For example, say I want to save a text file with some information on the app. Where would be an appropriate place to save it?
3
Upvotes
2
u/quickstatcheck Jan 05 '17
Assuming you're sandboxing, your options are pretty similar to iOS. In that case you would probably use either NSUserDefaults or write a file to the directory found by using NSFileManager's URLsForDirectory:inDomains:, depending on what you're trying to accomplish.
1
u/[deleted] Jan 06 '17
Use
NSSearchPathForDirectoriesInDomainswith differentSearchPathDirectoryconstant. This way you get paths for different directories. E.g. cache, library, documents, documentation, etc.