O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

For the More Curious: Are You Drawing to the Screen?

In an application, you will often want to draw things differently on screen than on the printer. For example, in a drawing program, the on-screen view might show a grid on-screen but not when printed on paper.

In your drawRect(_:) method, you can ask the current graphics context if it is currently drawing to the screen:

i​f​ ​N​S​G​r​a​p​h​i​c​s​C​o​n​t​e​x​t​.​c​u​r​r​e​n​t​C​o​n​t​e​x​t​D​r​a​w​i​n​g​T​o​S​c​r​e​e​n​(​)​ ​{​
 ​ ​ ​ ​/​/​ ​.​.​.​ ​d​r​a​w​ ​t​h​e​ ​g​r​i​d​ ​.​.​.​
}​

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required