• 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: Relative pathnames e.g. when initializing NSImages?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Relative pathnames e.g. when initializing NSImages?


  • Subject: Re: Relative pathnames e.g. when initializing NSImages?
  • From: email@hidden
  • Date: Sat, 11 May 2002 16:37:52 +0200

On samedi, mai 11, 2002, at 04:14 , Nathan Groh wrote:

When using NSImage's initWithContentsOfFile: method, I'm forced to use an absolute pathname. A standard Unix relative pathname invariably fails. Is there some special Darwin voodoo regarding relative paths that I'm in the dark about? I've tried both a relative path from the application, e.g. @"Graphics/image.tiff" where Graphics is the folder containing the app's images, and a relative path from the user's home directory e.g. @"~/Application/Graphics/image.tiff". Both paths fail to initialize the NSImage successfully, and I'm forced to use a path like @"/Users/theuser/Application/Graphics/image.tiff". Obviously I'm missing something. Can someone shed some light on the situation for me? Fiat lux. : )

1 quick suggestion:

Use [@"~/Application/Graphics/image.tiff" stringByExpandingTildeInPath]

Another suggestion:

Use the App bundle to store your images, it will allow you to use [NSImage imageNamed:];
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: Relative pathnames e.g. when initializing NSImages?
      • From: Nathan Groh <email@hidden>
References: 
 >Relative pathnames e.g. when initializing NSImages? (From: Nathan Groh <email@hidden>)

  • Prev by Date: Relative pathnames e.g. when initializing NSImages?
  • Next by Date: Re: Relative pathnames e.g. when initializing NSImages?
  • Previous by thread: Relative pathnames e.g. when initializing NSImages?
  • Next by thread: Re: Relative pathnames e.g. when initializing NSImages?
  • Index(es):
    • Date
    • Thread