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
public protocol ApiRequestSetting { | |
static var hostname: String { get } | |
static var basePath: String { get } | |
} | |
final class StubConfigurator { | |
private let setting: ApiRequestSetting.Type | |
init(setting: ApiRequestSetting.Type) { |
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 | |
import UIKit | |
import XCPlayground | |
import PlaygroundSupport | |
let viewController = UIViewController() |
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 | |
import XCPlayground | |
import PlaygroundSupport | |
let viewController = UIViewController() | |
viewController.view.backgroundColor = .white |
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 someFunc(a: Int, b: Int) -> String { | |
return "a = \(a), b = \(b)" | |
} | |
let parameters = (a: 0, b: 0) | |
// someFunc(parameters) // not allowed in swift 3 | |
let numbers: [Int] = [1, 2, 3] | |
numbers | |
.map { number -> (a: Int, b: Int) in |
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 MyError: Error { | |
} | |
//// Signal | |
print("------ Signal basic ------") | |
let (signal, innerObserver) = Signal<Int, MyError>.pipe() | |
signal.observeResult { result in | |
switch result { |
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
// case 1: using pipe | |
class A { | |
let signal: Signal<Void, NoError> | |
let observer: Signal<Void, NoError>.Observer | |
init() { | |
(signal, observer) = Signal<Void, NoError>.pipe() | |
} | |
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 XibInstantiatable { | |
func instantiate() | |
} | |
extension XibInstantiatable where Self: UIView { | |
func instantiate() { | |
let nib = UINib(nibName: String(self.dynamicType), bundle: nil) | |
guard let view = nib.instantiateWithOwner(self, options: nil).first as? UIView else { | |
return | |
} |
NewerOlder