Re: ScreenSaverView gets instantiated several times
Re: ScreenSaverView gets instantiated several times
- Subject: Re: ScreenSaverView gets instantiated several times
- From: Michael Babin <email@hidden>
- Date: Mon, 5 Oct 2009 10:02:09 -0500
On Oct 5, 2009, at 3:39 AM, Gabriel Zachmann wrote:
When the user clicks 'Test' in System Preferences, it "just"
creates a new instance of your subclass of ScreenSaverView!
Do you really find that fact to be "shocking"?
Yes, I do.
[snip]
If only Apple would have said so in big letters at the beginning of
the docs of ScreenSaverView!
The documentation on creating screen savers is pretty sparse, no
argument here. There are also sample screen savers available from the
developer site, as well as other sources that can help you understand
more about the environment you're entering. The absence of documented
details may lead you to making some assumptions about how your screen
saver objects are created and the environment in which they operate,
but it is important to test those assumptions before you get too far
down the road.
I can see being "surprised" when an assumption proves to be
inaccurate. I would reserve "shocked" for situations where the
documentation is inaccurate or the actual implementation seems to be
in contradiction with patterns found in other frameworks.
What did you suppose would happen (not that suppositions and
assumptions are worth much)?
I supposed that the screen saver manager would just call -
initWithFrame: again.
As Uli pointed out previously, calling -initWithFrame: (or any init
method) multiple times on one object is not a pattern you find in
other classes/frameworks. You might have assumed a call to -setFrame:,
if you assumed the same view was being used and resized, but that
would be easy to test to verify your assumption.
Extra credit: the user has multiple displays attached, "Main screen
only" option is off, and the user clicks the Test button or
activates your screen saver (hot corner, inactivity). What do you
expect will happen then?
I assumed it would load(!) & run the screen saver bundle multiple
times.
And it's not that this assumption is complete nonsense, is it?
Depending upon your knowledge of bundles, it wouldn't be an outrageous
assumption to make. As Uli pointed out, there are reasons this isn't
the case. This assumption would again be something important to test
early in development.
What actually does happen?
With multiple displays I have no idea, since I've got only one
display.
But now I "assume" that it loads the bundle once and creates
multiple instances ...
Yes, one ScreenSaverView per display. Admittedly, this is a tougher
assumption to test if you don't have access to a machine with multiple
displays.
it's really just a way to say "Yes, you must be prepared for
multiple instances of your screen saver view to exist
simultaneously".
Again, if only Apple would have said that in the docs!
Here's another one (newly introduced) that isn't in the docs (as far
as I know): to run on Snow Leopard on a machine whose processor is
capable of running in 64-bit mode (all currently shipping Macs), you
will need a 64-bit version of your screen saver with GC supported. To
run on Leopard and earlier, as well as on Snow Leopard on machines
whose processor is not capable of running in 64-bit mode (Core Solo,
Core Duo), you will need a 32-bit version of your screen saver with GC
off.
Good luck!
- 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