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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to