• 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: +bundleForClass: category question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: +bundleForClass: category question


  • Subject: Re: +bundleForClass: category question
  • From: Uli Kusterer <email@hidden>
  • Date: Sat, 21 Jul 2012 15:26:53 +0200

On 16.07.2012, at 04:30, Graham Cox wrote:
> If I create a category on a standard framework class as part of another framework, and I use +[NSBundle bundleForClass:] to load an image resource for use by that category, does that work, i.e. does it load the bundle of the framework containing the category, or the bundle containing the original class being extended?


 You'll always get the bundle where the class was originally defined, not your category's. A workaround that I occasionally do in categories is that I define a dummy "anchor" class next to the category and call -bundleForClass: on that. Very useful for code that is used on iOS (there are no frameworks) and on the Mac (in a framework). It'll always grab the bundle to which someone added that source file, and the assumption is whoever did that also copied along the resources.

-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.masters-of-the-void.com




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: 
 >+bundleForClass: category question (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Cell in Selected NSTableView Not Redrawn
  • Next by Date: Re: Cell in Selected NSTableView Not Redrawn
  • Previous by thread: Re: +bundleForClass: category question
  • Next by thread: Re: Cocoa-dev Digest, Vol 9, Issue 488
  • Index(es):
    • Date
    • Thread