• 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: is a repetitive use of imageNamed: bad?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >is a repetitive use of imageNamed: bad? (From: Olivier Lanctôt <email@hidden>)

  • Prev by Date: is a repetitive use of imageNamed: bad?
  • Next by Date: Re: Newbie needs help with tableview and bindings
  • Previous by thread: is a repetitive use of imageNamed: bad?
  • Next by thread: expose hotkeys
  • Index(es):
    • Date
    • Thread