Skip to content

Instantly share code, notes, and snippets.

// swiftlint:disable line_length
// swiftlint:disable variable_name
import Foundation
#if os(iOS) || os(tvOS) || os(watchOS)
import UIKit
#elseif os(OSX)
import AppKit
#endif
final class LockValue<T> {
private var value: T
private let lock: NSRecursiveLock
// MARK: - Initializer
init(value: T) {
self.value = value
self.lock = NSRecursiveLock()
}
@babzich
babzich / Either.swift
Last active September 7, 2017 14:23
Very basic implementation of Either in Swift
enum Either<A, B> {
case left(A)
case right(B)
var left: A? {
return fold({ $0 }, { _ in nil })
}
var right: B? {
return fold({ _ in nil }, { $0 })
protocol HasNetworkDependency {
var networkService: NetworkServiceProtocol { get }
}
protocol HasLoggerDependency {
var logger: LoggerProtocol { get }
}
protocol HasAnalyticsTrackerDependency {
var analyticsTracker: AnalyticsProtocol { get }
//
// UITextField+BABAdditions.h
//
// Created by Vincent Bach on 06/09/15.
// Copyright © 2015 Vincent Bach. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UITextField (BABAdditions)