Re: NSImage imageNamed
Re: NSImage imageNamed
- Subject: Re: NSImage imageNamed
- From: Tom Waters <email@hidden>
- Date: Sun, 8 Jul 2001 10:39:27 -0700
Duh... it's a "nevermind" on both issues...
My image not showing up was a bug in my code, it was getting drawn
offscreen the first time... how embarrassing!
The second issue is solved by RTFM... I knew I wasn't retaining them for
a reason... Images retrieved with imageNamed are kept in memory by the
cocoa mechanism keeps the map between the name and the image...
subsequent calls to imageNamed with the same name, return the same image
instance. So you are free to retain and release it if you want, but it
is not strictly necessary.
From the reference to NSImage...
The image returned by this method should not be freed, unless it's
certain that no other objects reference it.
On Sunday, July 8, 2001, at 09:42 AM, Kyle Mandli wrote:
>
I use this function a lot and I don't seem to have any problems with it
>
although make sure you are retaining it correctly. You will need to do
>
something to this affect...
>
>
NSImage *myImage = [[NSImage imageNamed:@"image.jpg"] retain];
>
>
I usually create the instance in initWithFrame: and it seems to work
>
there.