Skip to content

Instantly share code, notes, and snippets.


Joseph El Mallah joseph-elmallah

View GitHub Profile
joseph-elmallah / GameOfLifeJ2ObjC.swift
Last active Apr 12, 2019
Game of life using J2ObjC
View GameOfLifeJ2ObjC.swift
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
joseph-elmallah / UIApplication+URLHandler.swift
Created Dec 9, 2018
The conformance of UIApplication to the URLHandler protocol
View UIApplication+URLHandler.swift
// 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)
joseph-elmallah / URL+UIResponder.swift
Created Dec 9, 2018
A decoupled way to propagate URL opening in an iOS app over the Responder chain
View URL+UIResponder.swift
/// 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
joseph-elmallah / UIResponder+BasicErrorPropagation.swift
Last active Sep 1, 2018
Basic UIResponder for iOS error propagation
View UIResponder+BasicErrorPropagation.swift
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