How do I get getpwuid to work in my mac app?

667 views Asked by At

I'm trying to get my sandboxed mac app to get to the user's real home folder.

This is what I tried

const char *home = getpwent()->pw_dir;
NSString *path = [[NSFileManager defaultManager] 
              stringWithFileSystemRepresentation:home
              length:strlen(home)];
NSURL *url = [NSURL fileURLWithPath:path isDirectory:YES];

But I'm getting this error:

Member reference type 'int' is not a pointer

What am I missing?

1

There are 1 answers

0
dot On BEST ANSWER

I forgot to

 #include <pwd.h>

I'll leave the question up in case someone else has trouble with it!