Re: +bundleForClass: category question
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