func announce()

in tutorials/tutorial4/TicTacToe/RandomWin/RandomWinViewController.swift [51:66]


    func announce(winner: PlayerType, withCompletionHandler handler: @escaping () -> ()) {
        let winnerString: String = {
            switch winner {
            case .player1:
                return "\(player1Name) Won!"
            case .player2:
                return "\(player2Name) Won!"
            }
        }()
        let alert = UIAlertController(title: winnerString, message: nil, preferredStyle: .alert)
        let closeAction = UIAlertAction(title: "That was random...", style: UIAlertActionStyle.default) { _ in
            handler()
        }
        alert.addAction(closeAction)
        present(alert, animated: true, completion: nil)
    }