[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem loading a picture.

From: Chris B. Vetter
Subject: Re: Problem loading a picture.
Date: Mon, 15 Mar 2004 10:15:21 -0800

On Fri, 12 Mar 2004 18:26:55 +0100
Nicolas SANCHEZ <> wrote:
> in the source code:
> NSImage *img = [[NSImage alloc] initWithContentsOfFile:
> @"CameraTransfer_header.tiff"]];

This will try to init NSImage with the content of a file that resides in
the current directory (ie. the directory you start the application from)

Because CameraTransfer_header.tiff resides directly in your source
directory, the image will be loaded and NSImage is created.

> but somebody helps me to find this (which works):
> NSImage *img = [[NSImage alloc] initWithContentsOfFile: [[NSBundle
> mainBundle] pathForImageResource: @"CameraTransfer_header.tiff"]];

This works, because -pathForImageResource: looks at what is specified
'under' CameraTransfer_RESOURCE_FILES in your GNUmakefile. The tiff is
copied into and the above statement will
load the tiff from there...

A 'shortcut' would be

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

> But I think that the first code should works also, shouldn't it ?

It should not and cannot.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]