Re: Screen Savers
Re: Screen Savers
- Subject: Re: Screen Savers
- From: Michael Ash <email@hidden>
- Date: Sat, 11 Apr 2009 00:14:54 -0400
On Fri, Apr 10, 2009 at 5:49 PM, Nicko van Someren <email@hidden> wrote:
> On 10 Apr 2009, at 12:46, Dave Keck wrote:
>
>> To get the path to a bundle that's loaded inside an arbitrary process,
>> I create a stub subclass of NSObject (let's call it MyStubClass) and
>> simply call [NSBundle bundleForClass: [MyStubClass class]];
>>
>> This technique is the most straightforward way I know of to accomplish
>> what you're looking for - it's never failed me. A little precaution
>> though: to avoid potential conflicts, be sure to name your stub class
>> something a little more unique than 'MyStubClass' :)
>
> Since this is being done in the context of a screen saver presumably the
> code doing this is somewhere inside the sub-class of a ScreenSaverView that
> defines the screen saver. If this is the case you should be able to just
> use [NSBundle bundleForClass: [self class]];
Although this is probably fine in a screensaver, you should always use
an explicit class name instead of [self class]. The reason for this is
that [self class] will give you bad results if your class is
subclassed outside your bundle (which is unlikely but possible for
plugins, and pretty likely for frameworks) resulting in mysterious
failures. Use [MyClassName class] instead for assured results.
Mike
_______________________________________________
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