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​ ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.