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

Drawing Text Die Faces

Open DieView.swift and jump to drawDieWithSize(_:). Add the following code below the block that draws the die dots. The new code will run if intValue is not in the range 1...6.

 ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​i​f​ ​i​n​t​V​a​l​u​e​ ​=​=​ ​6​ ​{​
 ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​d​r​a​w​D​o​t​(​0​,​ ​0​.​5​)​ ​/​/​ ​M​i​d​ ​l​e​f​t​/​r​i​g​h​t​
 ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​d​r​a​w​D​o​t​(​1​,​ ​0​.​5​)​
 ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​}​
 ​ ​ ​ ​ ​ ​ ​ ​}​
 ​ ​ ​ ​ ​ ​ ​ ​e​l​s​e​ ​{​
 ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​v​a​r​ ​p​a​r​a​S​t​y​l​e​ ​=​ ​N​S​P​a​r​a​g​r​a​p​h​S​t​y​l​e​.​d​e​f​a​u​l​t​P​a​r​a​g​r​a​p​h​S​t​y​l​e​(​)​.​m​u​t​a​b​l​e​C​o​p​y​(​)​
 ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​a​s​!​ ​N​S​M​u​t​a​b​l​e​P​a​r​a​g​r​a​p​h​S​t​y​l​e ...

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