• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Irritating Problem with NSString Method and File Paths
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Irritating Problem with NSString Method and File Paths


  • Subject: Re: Irritating Problem with NSString Method and File Paths
  • From: Phil <email@hidden>
  • Date: Mon, 4 Aug 2008 17:01:35 +1200

On Mon, Aug 4, 2008 at 4:43 PM, Patrick Walker <email@hidden> wrote:
> It seems that whenever I use Xcode to spawn the program, it is able to find
> the file but when spawning the program from Finder, it can never, ever find
> the file.  I've been looking online and no one seems to have come across
> this before or maybe it's because it's so late that I'm not seeing the
> obvious.
>

This is because the current working directory is different when an
application is launched through Finder (vs. Xcode or the terminal).
You can check the current working directory with NSFileManager's
-currentDirectoryPath; Xcode sets this to the directory your
application bundle is in, Finder sets it to "/".

I'd recommend using NSBundle to figure out where your application, and
use the NSString path manipulation methods:
    [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:filename]

Phil
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Irritating Problem with NSString Method and File Paths (From: Patrick Walker <email@hidden>)

  • Prev by Date: Irritating Problem with NSString Method and File Paths
  • Next by Date: How to get the current affine transform
  • Previous by thread: Irritating Problem with NSString Method and File Paths
  • Next by thread: Re: Irritating Problem with NSString Method and File Paths
  • Index(es):
    • Date
    • Thread