macosmac-app-storegetpwuid

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


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?


Solution

  • I forgot to

     #include <pwd.h>
    

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