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

  • SEARCH
  • Home
  • 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 7812723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:36:20+00:00 2026-06-02T04:36:20+00:00

i have an application on Xcode 4 for osx. In my program i have

  • 0

i have an application on Xcode 4 for osx. In my program i have some places where i need to read and write to a plist file. currently i have used a file path of /users/my name/desktop/name of document plist. however naturally when i make the application into a app and transfer it to a different computer it is not able to find and read the files. what should i make the file path so that it works on any computer. below is my file path that i have

filepath = @"/Users/Gautambir/Desktop/CustomerNames.plist"
  • 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-06-02T04:36:21+00:00Added an answer on June 2, 2026 at 4:36 am

    You should never, ever, hard-code paths. You should construct your paths using the various APIs available to do so.

    There are several ways to construct valid paths. For instance, this works:

    NSString* filePath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Desktop"] stringByAppendingPathComponent:@"CustomerNames.plist"];
    

    Alternatively, you could use:

    NSString* filePath = [@"~/Desktop/CustomerNames.plist" stringByExpandingTildeInPath];
    

    Although these are correct ways to build a path, to access special locations such as the Desktop, the Documents folder or the Application Support folder, you should use the NSSearchPathForDirectoriesInDomains() function or, preferably, the NSFileManager methods URLsForDirectory:inDomains: or URLForDirectory:inDomain:appropriateForURL:create:error:.

    These URL-based method should always be preferred over their path-based equivalents. Apple recommends all developers move to support the URL-based methods as soon as practicable.

    This is primarily because file URLs can store bookmark data, so that if a file moves the URL can still be resolved, which is not the case with paths as paths are just strings and can’t store metadata.

    Here’s how you’d use the file manager to find your URL:

    NSFileManager* fm = [NSFileManager defaultManager];
    NSURL* desktopURL = [fm URLForDirectory:NSDesktopDirectory 
                                inDomain:NSUserDomainMask 
                       appropriateForURL:nil
                            shouldCreate:NO
                                   error:nil];
    
    NSURL* fileURL = [desktopURL URLByAppendingPathComponent:@"CustomerNames.plist"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used the Validate tool in xcode and validated my application. The validation
I have a mac application(written with xcode) i have to write a .net application
I am playing around with clucene under mac osx with xcode and have some
I have a master detail Application in xCode. In Master View Controller an Array
I have snow leopard and I'm building a cpp Application with xcode. I would
How can I self-sign an iPhone application using Xcode? I have done the following:
Possible Duplicate: Xcode: Storyboard Tabbed Application Passing Data Back and Forth Basically I have
I have created a page-based application in Xcode 4, for iPad iOS5. When I
I have created a simple hello world application in xcode using the command line
I have an Xcode project which builds a Cocoa desktop Browser application. My Browser

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.