Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7586549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:27:19+00:00 2026-05-30T19:27:19+00:00

NSHomeDirectory() is returning my sandbox root, not my home directory. [@"~" stringByExpandingTildeInPath] is doing

  • 0

NSHomeDirectory() is returning my sandbox root, not my home directory. [@"~" stringByExpandingTildeInPath] is doing the same thing.

This /Users/username/Library/Containers/appID/Data is what’s being returned. How do I get /Users/username/?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:27:21+00:00Added an answer on May 30, 2026 at 7:27 pm

    If you want the path to the user’s real home directory you can use:

    char *realHome = getpwuid(getuid())->pw_dir;
    

    Full example:

    #include <unistd.h>
    #include <sys/types.h>
    #include <pwd.h>
    #include <assert.h>
    
    NSString *RealHomeDirectory() {
        struct passwd *pw = getpwuid(getuid());
        assert(pw);
        return [NSString stringWithUTF8String:pw->pw_dir];
    }
    

    This gives you the path to the user’s home, but does not automatically give you access to that folder. As noted in comments, you can use this path for:

    • providing a sane default folder for the open/save dialogs
    • detecting whether you are in a sandbox, by comparing the result to NSHomeDirectory()
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the NSHomeDirectory() function to get the app's home folder, and write to
I'm trying to create image from this location : NSString *documentsCacheDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@Documents];
What's wrong with that? #define AUDIO_NOTES_FOLDER [NSHomeDirectory() stringByAppendingPathComponent:@Documents/myApp/Pictures] NSFileManager *NSFm= [NSFileManager defaultManager]; BOOL isDir=YES;
I have the following code in place: - (void)viewDidLoad { NSString *homeDirectoryPath = NSHomeDirectory();
I am working on an app which will upload videos to a Facebook users
How can I remove all of the photos that I've saved in NSHomeDirectory ?
I'd like to assign a boolean value to a plist file entry. I'm doing
I am using UIImagePickerController for bring images from the photo library, i found this
What I am doing is to save an image loaded from any source,(camera /
Scroll down to EDIT 1. This top bit is irrelevant now. This is my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.