Skip to content

Instantly share code, notes, and snippets.

View yoching's full-sized avatar
👋

Yoshikuni Kato yoching

👋
View GitHub Profile
@yoching
yoching / StubConfigurator.swift
Created September 19, 2017 03:16
OHHTTPStubs wrapper
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) {
@yoching
yoching / FunctionalViewStyleExperiments2.swift
Created September 7, 2017 07:35
FunctionalViewStyleExperiments2
//: Playground - noun: a place where people can play
import UIKit
import UIKit
import XCPlayground
import PlaygroundSupport
let viewController = UIViewController()
@yoching
yoching / FuctionalViewStyleExperiments1.swift
Last active September 7, 2017 07:34
FuctionalViewStyleExperiments1
//: Playground - noun: a place where people can play
import UIKit
import XCPlayground
import PlaygroundSupport
let viewController = UIViewController()
viewController.view.backgroundColor = .white
@yoching
yoching / experiment.swift
Last active May 30, 2017 03:32
swift tuple parameter experiments
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
@yoching
yoching / ReactiveSwiftBasicComponentSamples.swift
Last active July 31, 2018 07:21
ReactiveSwift basic components samples
struct MyError: Error {
}
//// Signal
print("------ Signal basic ------")
let (signal, innerObserver) = Signal<Int, MyError>.pipe()
signal.observeResult { result in
switch result {
@yoching
yoching / RACSignalExperiments.swift
Last active August 3, 2016 14:24
Questions about RAC signal deallocation.
// case 1: using pipe
class A {
let signal: Signal<Void, NoError>
let observer: Signal<Void, NoError>.Observer
init() {
(signal, observer) = Signal<Void, NoError>.pipe()
}
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
}