This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
// This is a snippet for the Medium article: | |
// UIViewController that shows a board of 10x10 cells of Game of Life implementation. | |
class ViewController: UIViewController, GofCoreDisplayDriver { | |
/// The board is square. This defines the edge size of the board (10 x 10) | |
private let boardSize: Int = 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - URLHandler conformance | |
extension UIApplication: URLHandler { | |
func handleURL(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey : Any], completionHandler completion: ((Bool) -> Void)?) { | |
// If we reach the end of the responder chain without anyone handeling the URL, ask the Applciation to handle it | |
open(url, options: options, completionHandler: completion) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Conforming to this protocol allows for URL handling | |
protocol URLHandler { | |
/// Handle a URL | |
/// | |
/// - Parameter url: The propagated url | |
/// - Returns: The handled status | |
func handleURL(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey : Any], completionHandler completion: ((Bool) -> Void)?) | |
} | |
// MARK: - Error Propagation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
// The status of an error handler | |
enum ErrorHandlingStatus { | |
/// The error was handled successfully and the propagation should stop | |
case handled | |
/// The error was not handled and the should be propagated further more | |
case unhandled | |
} |