Re: is a repetitive use of imageNamed: bad?
Re: is a repetitive use of imageNamed: bad?
- Subject: Re: is a repetitive use of imageNamed: bad?
- From: Ryan Britton <email@hidden>
- Date: Thu, 24 Nov 2005 09:38:07 -0800
Once an image is loaded using that, it is cached internally in a
table. Any future calls to it with the same name will return the
same image without having to load it from disk.
From the docs:
NSImage keeps a reference to the image in a table until the image
name is cleared. Consequently you do not need to retain the returned
image object unless its name could be cleared. You clear an image
name by sending the associated NSImage object a setName: message with
an argument of nil. This message removes the image from the table and
autoreleases the object. However, if the image has been fetched
elsewhere using imageNamed:, then those instances could still be used.
On Nov 24, 2005, at 9:25 AM, Olivier Lanctôt wrote:
Hi list,
I want to ask a simple question.
Imagine a view that always draws a background, which is a NSImage.
Is it bad to always invoke imageNamed: every time -drawRect: is
called?
Yes, it's one more objc message, but is there internal caching that
prevents NSImage from accessing the HD again and again?
Is it better to declare the image as an ivar or a static on the file
and init it at -init?
Thanks!
--
Olivier
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden