NSGraphics class is the programmatic interface to objects that represent graphics contexts. A context can be thought of as a destination to which drawing and graphics state operations are sent for execution. Each graphics context contains its own graphics environment and state.
- macOS 10.0+
NSGraphics class is an abstract superclass for destination-specific graphics contexts. You obtain instances of concrete subclasses with the class methods
At any time there is the notion of the current context. The current context for the current thread may be set using
Graphics contexts are maintained on a stack. You push a graphics context onto the stack by sending it a
save message, and pop it off the stack by sending it a
restore message. By sending
restore to an
NSGraphics object you remove it from the stack, and the next graphics context on the stack becomes the current graphics context.