• 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: Named images in linked frameworks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Named images in linked frameworks


  • Subject: Re: Named images in linked frameworks
  • From: Scott Stevenson <email@hidden>
  • Date: Fri, 24 Nov 2006 15:52:19 -0800


On Nov 24, 2006, at 11:21 AM, Claudio Procida wrote:

I read in the Cocoa Drawing Guide that before using an image resource present in a bundle, I have to load it and explicitly set its name.

Nope. The answers you seek are here:

<http://developer.apple.com/documentation/Cocoa/Reference/ ApplicationKit/Classes/NSImage_Class/Reference/Reference.html#// apple_ref/occ/clm/NSImage/imageNamed:>

The abridged version is that [NSImage imageNamed:@"Something"] will search:

1. The named image cache (things set with -setName:)
2. The application bundle for a file with the name
3. AppKit itself

Now if you do want to load a file from a path and set a name explicitly in initialize, that's fine too. It might be more efficient. You can also add images to the NIB file in Interface Builder.


What troubles me is that if I uncomment the -autorelease messages, the resources suddenly disappear during runtime. So I have to leave those objects lying around during execution.

The references you have to those specific object instances (that particular pointer) would go away, but new references to the same image can be generated any time using +imageNamed:. The images stay registered in the name table.



- Scott



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Named images in linked frameworks (From: Claudio Procida <email@hidden>)

  • Prev by Date: Re: How can I get an instance specific identifier?
  • Next by Date: How can I copy/duplicate an existing NSTextField?
  • Previous by thread: Named images in linked frameworks
  • Next by thread: How can I get an instance specific identifier?
  • Index(es):
    • Date
    • Thread