• 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: filePath issue?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: filePath issue?


  • Subject: Re: filePath issue?
  • From: Sherm Pendley <email@hidden>
  • Date: Fri, 9 Feb 2007 06:06:50 -0500

On Feb 9, 2007, at 1:51 PM, CoreX2 wrote:

hello everyone, there is a problem about the file path.
I want to generate a NSImage instance with the method:
- initByReferencingFile:(NSString *) filename;
If I want to use the relative path, for example : I add a .png file to my project, then How should I use the png file: juse use the relative path or the absolute path?
It seems that the absolute path is not the adoptable method to solve the problem. But if to use the relative path, what path should I refer: the path linking to my project?

Relative paths are not an option, because the base path to which they relate is unreliable. When you start your app from xCode, the base path is the build directory, when you start it from Finder it's "/", and when you start it with an "open" command from a shell prompt it's the shell environment's current working directory.


If you've added foo.png to your project, it'll be copied into the Resources/ directory in your .app bundle, and you can create an NSImage from it with [NSImage imageNamed:@"foo.png"].

sherm--

Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: 
 >filePath issue? (From: CoreX2 <email@hidden>)

  • Prev by Date: filePath issue?
  • Next by Date: Re: Cocoa fonts anti-aliasing issues
  • Previous by thread: filePath issue?
  • Next by thread: Re: filePath issue?
  • Index(es):
    • Date
    • Thread