Re: +bundleForClass: category question
Re: +bundleForClass: category question
- Subject: Re: +bundleForClass: category question
- From: Kyle Sluder <email@hidden>
- Date: Mon, 16 Jul 2012 18:10:52 -0700
On Tue, Jul 17, 2012, at 11:02 AM, Graham Cox wrote:
>
> What I'm trying to do is to add a couple of cursors to NSCursor using a
> category which are created by loading images from the framework's
> resources. Unfortunately it doesn't work when implemented in a simple way
> because +bundleForClass returns the bundle containing NSCursor. Instead I
> have to declare an intermediate class that loads the image resource for
> me - I was just hoping to avoid that extra step but seems not.
Since the identifier of the bundle is known at compile time, we have a
compile-time define that we use whenever we need to provide an NSBundle
in a situation like this:
https://github.com/omnigroup/OmniGroup/blob/master/Frameworks/OmniBase/OBUtilities.h#L64
Basically, we define OMNI_BUNDLE_IDENTIFIER in the Xcode project, use
the "Preprocess Info.plist" option to insert it into the
CFBundleIdentifier property, and use OMNI_BUNDLE whenever we need to
provide a "this-bundle"-relative NSBundle argument. OMNI_BUNDLE
essentially expands to [NSBundle bundleWithIdentifier:OMNI_BUNDLE].
--Kyle Sluder
_______________________________________________
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