This file contains 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
enum ControlFactoryError: ErrorType { | |
case TypeNotFound | |
} | |
protocol ControlFactory { | |
func create<T>(t: T.Type) throws -> UIView | |
} | |
class RealControlFactory: ControlFactory { | |
typealias FactoryItem = ()->(UIView) |
This file contains 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
protocol Copyable { | |
associatedtype V | |
func copy() -> V | |
func setup(v: V) -> V | |
} | |
class One: Copyable { | |
typealias V = One | |
var name: String? | |
This file contains 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
enum Result<T> { | |
case Success(T) | |
case Failure(ErrorType?) | |
init() { | |
self = .Failure(nil) | |
} | |
init(_ f: () throws->T) { | |
do { |
This file contains 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
protocol Atomic { | |
var value: Int { get } | |
func increment() | |
} | |
class SwiftAtomic: Atomic { | |
private let counter = ManagedAtomic<Int>(0) | |
var value: Int { |