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
| final class UTContainer<T> { | |
| var value: T { | |
| didSet { | |
| if self.fired { | |
| self.fired = false | |
| self.timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: NSBlockOperation { [weak self] in | |
| guard let strongSelf = self else { | |
| return | |
| } | |
| strongSelf.fired = true |
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 | |
| enum Error: ErrorType { | |
| case ERROR(ErrorType) | |
| } | |
| var error: ErrorType = Error.ERROR(NSCocoaError.CoderReadCorruptError) | |
| switch error { | |
| case Error.ERROR(NSCocoaError.CoderReadCorruptError): |
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
| enum Error1<E1: ErrorType> { | |
| case ERROR1(E1) | |
| init?(error: ErrorType) { | |
| if let error = error as? E1 { | |
| self = .ERROR1(error) | |
| } | |
| return nil | |
| } | |
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 Foundation | |
| enum URLMatchResult<T> { | |
| case Match(T) | |
| case Mismatch | |
| } | |
| protocol URLHandlerBaseType { | |
| func handle(url: NSURL) | |
| } |
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
| func wrap<A, B, C>(f: A -> B -> C) -> (A -> Any -> Any) { | |
| return { a1 in { a2 in f(a1)(a2 as! B) } } | |
| } | |
| protocol Dynamic { | |
| static var functions: [Selector: Self -> Any -> Any] { get } | |
| func dynamicInvoke(f: Selector, arg: Any) -> Any | |
| } | |
| extension Dynamic { |
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
| struct AnyJSON { | |
| enum Error: Swift.Error { | |
| case failToTransform | |
| } | |
| let rawValue: Any | |
| static func transformer() -> Transformer<AnyJSON, String> { | |
| return Transformer { (anyJSON) throws -> String in | |
| switch anyJSON.rawValue { |
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
| // | |
| // Extensions.swift | |
| // Barrel_Himotoki | |
| // | |
| // Created by Nobuo Saito on 2016/11/22. | |
| // Copyright © 2016年 line. All rights reserved. | |
| // | |
| import Foundation | |
| import Himotoki |
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
| protocol TypedError: Error { | |
| init(error: Error) | |
| } | |
| struct AnyError: TypedError { | |
| let error: Error | |
| init(error: Error) { | |
| self.error = error | |
| } | |
| } |
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 Foundation | |
| enum TransitioningMode { | |
| case present | |
| case dismiss | |
| } | |
| struct TransitioningContext<Presenting: UIViewController, Presented: UIViewController> { | |
| let native: UIViewControllerContextTransitioning | |
| let mode: TransitioningMode |
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
| //: Playground - noun: a place where people can play | |
| import UIKit | |
| protocol ViewModelType { | |
| associatedtype ViewType | |
| associatedtype ModelType | |
| var base: ModelType { get } | |
| var fields: [String: Any] { get set } |