• 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: File Paths
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: File Paths


  • Subject: Re: File Paths
  • From: David Remahl <email@hidden>
  • Date: Sat, 23 Nov 2002 03:01:05 +0100

Seth,

Either you could do this:

NSImage *img = [NSImage imageNamed:@"AnImage.tiff"];

which will search your Resources folder for an image named AnImage.

Or you can do it like this:

NSString *imgPath = [[NSBundle mainBundle] pathForResource:@"AnImage" ofType:@"tiff"];
NSImage *img = [[NSImage alloc] initWithContentsOfFile:imgPath];

...

[img release];

/ rgds David

On Saturday, November 23, 2002, at 02:53 AM, Seth Willits wrote:

I've looked through a bunch of tutorials and stuff and none of them have an
example of creating a path to access a file in a bundles Resources
directory, and then open that file as an image so it can be drawn in a view.

I know I should go buy a book on Cocoa but I'm holding off, so all I have
are the tutorials on the web, and whatever reference and sample code I can
dig up.

Thanks...
_______________________________________________
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: File Paths
      • From: Seth Willits <email@hidden>
References: 
 >File Paths (From: Seth Willits <email@hidden>)

  • Prev by Date: File Paths
  • Next by Date: Re: File Paths
  • Previous by thread: File Paths
  • Next by thread: Re: File Paths
  • Index(es):
    • Date
    • Thread