Skip to content

Instantly share code, notes, and snippets.

@tek-nishi
Created January 24, 2019 09:10
Show Gist options
  • Save tek-nishi/c511ea4523273bc221e75d9641137b12 to your computer and use it in GitHub Desktop.
Save tek-nishi/c511ea4523273bc221e75d9641137b12 to your computer and use it in GitHub Desktop.
Get macOS Application Support Folder from SDK.
std::string getDocumentFolder()
{
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
if ([paths count] == 0)
{
// Error.
return std::string("");
}
NSString* applicationSupportDirectory = [NSString stringWithFormat:@"%@/%@",
[paths objectAtIndex:0],
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]];
std::string path = [applicationSupportDirectory UTF8String];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment