Re: How to correctly load the bundle of a screen saver
Re: How to correctly load the bundle of a screen saver
- Subject: Re: How to correctly load the bundle of a screen saver
- From: Gabriel Zachmann <email@hidden>
- Date: Mon, 17 Jan 2011 21:46:07 +0100
> I think that System Preferences, since it's loading plug-ins, requires that your classes have unique names. Otherwise, when it loads the plug-ins, the names conflict in the Objective-C runtime.
>
Thanks a lot!
I have found this error message in the syslog:
Class ArtSaverView is implemented in both /Users/zach/Library/Screen Savers/Foo.saver/Contents/MacOS/Foo and /Users/zach/Library/Screen Savers/Foo2.saver/Contents/MacOS/Foo2. One of the two will be used. Which one is undefined.
That explains a lot.
I have changed my code -- the good news is that most of the time, it works now; the bad news is that occasionally it does not work!
In the header file, I declare my class like this:
#ifdef SECOND_FOOSAVER_VIEW
#define FOOVIEW FooSaver2View
#else
#define FOOVIEW FooSaverView
#endif
@interface FOOVIEW : ScreenSaverView
{ ...
where SECOND_FOOSAVER_VIEW is declared in
Similarly, I refer only to FOOVIEW in FooView.m
In the initWithFrame method of FOOVIEW, I retrieve the bundle and plug-in name like so:
NSBundle * bundle = [NSBundle bundleForClass:[self class]];
exec_name_ = [[bundle infoDictionary] objectForKey:@"CFBundleName"];
NSLog(@"execname = %@\n", exec_name_ );
Now, everything works fine *most of the time*: I can run SystemPreferences, there is no more error message in syslog, I can select the different screen savers, set different preferences, the screen savers store them in the correct files, etc.
BUT occasionally, when I run SystemPreferences, both screen savers exhibit the same behavior, i.e., they loaded the same preferences! This is also reflected in the syslog, where both screen savers logged the same execname!
How can that happen?
Puzzled,
Gabriel.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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