Programmatically get path to Application Support folder
This is outdated, for current best practice use FileManager.default.urls(for:in:)
as in the comment by @andyvn22 below.
the Best practice is to use NSSearchPathForDirectoriesInDomains
with NSApplicationSupportDirectory
as "long winded" as it may be.
Example:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString *applicationSupportDirectory = [paths firstObject];
NSLog(@"applicationSupportDirectory: '%@'", applicationSupportDirectory);
NSLog output:
applicationSupportDirectory: '/Volumes/User/me/Library/Application Support'
Swift:
print(NSHomeDirectory())
or
print(FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first)
and
let yourString = String(FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first)