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
import Foundation | |
let queue = DispatchQueue(label: "test") | |
var threads: [Thread] = [] | |
for _ in 0..<100 { | |
queue.async { | |
threads.append(Thread.current) | |
// 1) if this line is not commented out | |
// 2) if this line is commented out |
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
weak var weakViewController: UIViewController? | |
_ = { | |
let viewController = UIViewController() | |
viewController.loadViewIfNeeded() // this line prevents from deallocation | |
weakViewController = viewController | |
}() | |
XCTAssertNil(weakViewController) // (fail) weakViewController = Optional(<UIViewController: 0x7fd55e705080>) |
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
import Quick | |
import RxSwift | |
final class MySpec: QuickSpec { | |
override func spec() { | |
verifyRxResourcesAreReleased() | |
it("fails") { | |
_ = Observable<Int>.interval(.seconds(1), scheduler: MainScheduler.instance).subscribe() | |
} |
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
class GradientMaskLineRenderer: LineChartRenderer { | |
override init(dataProvider: LineChartDataProvider, animator: Animator, viewPortHandler: ViewPortHandler) { | |
super.init(dataProvider: dataProvider, animator: animator, viewPortHandler: viewPortHandler) | |
} | |
override func drawFilledPath(context: CGContext, path: CGPath, fill: Fill, fillAlpha: CGFloat) { | |
let rect = viewPortHandler.contentRect | |
let colorSpace = CGColorSpaceCreateDeviceGray() | |
let bitmapContext = CGContext( |
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
class Cell { | |
private let viewBlock: () -> Void | |
init(viewBlock: @escaping () -> Void) { | |
self.viewBlock = viewBlock | |
} | |
deinit { | |
print(type(of: self), #function) | |
} |
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
// | |
// Date+ISO8601.swift | |
// SSFoundation | |
// | |
// Created by Suyeol Jeon on 19/09/2019. | |
// Copyright © 2019 StyleShare Inc. All rights reserved. | |
// | |
import Foundation |
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
class User: Hashable { | |
let name: String | |
let age: Int | |
init(name: String, age: Int) { | |
self.name = name | |
self.age = age | |
} | |
func hash(into hasher: inout Hasher) { |
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
playgroundShouldContinueIndefinitely() | |
class Reactor { | |
lazy var state: Observable<Int> = self.closure().concat(Observable<Int>.never()) | |
private lazy var closure: () -> Observable<Int> = self.closureImplementation() | |
deinit { | |
print("DEINIT SUCCESS!!!") | |
} |
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
//////////////////////////////////////////////////////////////////////////////// | |
// Usage // | |
//////////////////////////////////////////////////////////////////////////////// | |
struct JoinForm { | |
var emailField: FormField | |
var usernameField: FormField | |
init(email: String?) { | |
self.emailField = FormField(value: email) |