Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the location of the user folders on Mac OS X using Objective-C

Tags:

objective-c

How to get the location of the file in mac os using objective c?

/Users/objc/Downloads/x.pdf

Any foundation classes for this?

please give me some sample code.

like image 688
jonson Avatar asked Oct 15 '10 11:10

jonson


1 Answers

Not sure whether I understand what you want, but you get the user's home directory with:

NSArray *docDirs = NSSearchPathForDirectoriesInDomains(
                    NSDownloadsDirectory,
                    NSUserDomainMask, YES);
NSString *doc = [docDirs objectAtIndex:0];

And then you can construct the path:

NSString *path = [NSString stringWithFormat:@"%@/x.pdf", doc];
like image 157
DarkDust Avatar answered Sep 20 '22 01:09

DarkDust