Skip navigation.
 
mlRe: File Paths
FROM : David Remahl
DATE : Sat Nov 23 03:01:05 2002

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_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Related mailsAuthorDate
mlFile Paths Seth Willits Nov 23, 02:53
mlRe: File Paths David Remahl Nov 23, 03:01
mlRe: File Paths Seth Willits Nov 23, 03:20