Skip to content

Instantly share code, notes, and snippets.

@bzmario
bzmario / Swift Events
Last active October 14, 2015 10:37 — forked from ColinEberhardt/Swift Events
An eventing mechanism for Swift
// Based on https://gist.github.com/ColinEberhardt/05fafaca143ac78dbe09
// Make handler as closure type
protocol Disposable {
func dispose()
}
class Event<T> {
typealias Handler = (data: T) -> Void
private var handlers = [HandlerWrapper<T>]()
@bzmario
bzmario / 10.11_troubleshooting.md
Last active October 13, 2015 09:42 — forked from leecade/10.11_troubleshooting.md
10.11_troubleshooting

Xcode 7 error

simulator runtime is not available.
Unable to open liblaunch_sim.dylib Try reinstalling Xcode or the simulator runtime.

Solution:

@bzmario
bzmario / Result.swift
Last active September 7, 2015 09:25
Alternative to try?
// : Alternative to try? from Erica Sadun - http://ericasadun.com/2015/09/03/alternatives-to-try-swiftlang/
enum Result<T> {
case Value(T)
case Error(ErrorType)
init(_ block: () throws -> T) {
do {
let value = try block()
self = Result.Value(value)