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:
windowController.presentAsSheetOnWindow(window, completionHandler: { configuration in if let ...
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.