Introduction

Framework
Library/Frameworks/ScreenSaver.framework
Header file directories
Library/Frameworks/ScreenSaver.framework/Headers
Declared in
ScreenSaverDefaults.h
ScreenSaverView.h

The Screen Saver framework defines the interface for subclasses to interact with the Screen Effects user interface feature. Screen Effects modules need to be written in Objective-C with its user interface implemented using Cocoa.

Screen Saver Framework Classes

The Screen Saver framework consists of the ScreenSaverView class, an abstract subclass of NSView. ScreenSaverView defines an interface for animating screen savers, instantiating small preview versions of the screen saver view (for display in the system preferences, for example), and for providing a configuration sheet to set various properties of the screen saver.

The ScreenSaverDefaults class is a subclass of NSUserDefaults and provides an interface to the standard user preferences storage system.

In addition, the Screen Saver framework provides a number of functions commonly required by screen saver applications including producing random values and centering rectangles.

Call Order

When OS X starts your screen saver, the following things happen:

  1. The screen fades to black.

  2. Your module is instantiated and its init routine is called.

  3. The window is created.

  4. Your module is installed in the window.

  5. Your window is activated and its order is set. The drawRect call is called at this point.

  6. The screen fades in, revealing your window in the front.

  7. Your startAnimation method is called. This method should not do any drawing.

  8. Drawing continues. Your animateOneFrame is called repeatedly.

  9. The user takes some action.

  10. Your stopAnimation method is called.

Binary Compatibility

Because screen savers are plug-ins for the screen saver engine, a screen saver can only be supported if its binary contains a slice for the architecture of the running engine. As with any application, the screen saver engine normally runs using the most recent architecture supported by a given computer (assuming that the engine has a slice for that architecture).

For full compatibility, this means that on Intel-based Macs, a screen saver must contain (at least) an i386 slice (compiled for the oldest OS version you wish to support) and an x86_64 slice (compiled for version 10.6 and later). On PowerPC, OS X uses a 32-bit screen saver engine.