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

Challenge: Encapsulate Sheet Presentation

In Dice, add a method to ConfigurationWindowController: presentAsSheetOnWindow(_:completionHandler:). The method’s parameter should be the window the configuration sheet should be displayed on, and the completion handler will be a closure of type (DieConfiguration?)->(Void). If the user clicks OK, the DieConfiguration will be passed to the completion handler; otherwise it will be nil to signal that nothing changed.

Here is how your method will look when it is called:

 ​ ​ ​ ​ ​ ​w​i​n​d​o​w​C​o​n​t​r​o​l​l​e​r​.​p​r​e​s​e​n​t​A​s​S​h​e​e​t​O​n​W​i​n​d​o​w​(​w​i​n​d​o​w​,​ ​c​o​m​p​l​e​t​i​o​n​H​a​n​d​l​e​r​:​ ​{​ ​ ​ ​ ​ ​ ​ ​ ​c​o​n​f​i​g​u​r​a​t​i​o​n​ ​i​n​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​i​f​ ​l​e​t​ ...

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