Prepares the image to receive drawing commands.
- macOS 10.0+
This method sets the current drawing context to the area of the offscreen window used to cache the receiver's contents. Subsequent drawing commands are composited to this offscreen window. If the offscreen drawing area already has some content, any new drawing commands are composited with that content. This method does not modify the original image data directly.
When locking focus, this method chooses the best image representation object available and locks focus on that object. If the receiver has no image representations, this method creates one with the default depth and locks focus on it. For information on how the "best" representation is chosen, see the Images chapter of Cocoa Drawing Guide.
lock message must be balanced with a matching
unlock message to the same
NSImage object. These messages bracket the code that draws the image.
lock is unable to focus on the image, it raises an