Skip to content

Instantly share code, notes, and snippets.

👨‍💻
Always coding

Suyeol Jeon devxoul

👨‍💻
Always coding
Block or report user

Report or block devxoul

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View RuntimeQuiz.swift
// TODO: define type 'User'
func testCase1() {
let json: [String: Any] = [
"id": 1,
"usermname": "devxoul",
"email": "devxoul@gmail.com",
]
let user = User(json: json)
View 1_ThreadCurrent.swift
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
@devxoul
devxoul / UIViewControllerDeallocSync.swift
Last active Oct 16, 2019
Does UIViewController get deallocated synchronously? NO. (if view is loaded)
View UIViewControllerDeallocSync.swift
weak var weakViewController: UIViewController?
_ = {
let viewController = UIViewController()
viewController.loadViewIfNeeded() // this line prevents from deallocation
weakViewController = viewController
}()
XCTAssertNil(weakViewController) // (fail) weakViewController = Optional(<UIViewController: 0x7fd55e705080>)
@devxoul
devxoul / MySpec.swift
Last active Oct 15, 2019
Verify RxSwift resources and scheduler actions after finishing the tests.
View MySpec.swift
import Quick
import RxSwift
final class MySpec: QuickSpec {
override func spec() {
verifyRxResourcesAreReleased()
it("fails") {
_ = Observable<Int>.interval(.seconds(1), scheduler: MainScheduler.instance).subscribe()
}
View GradientMaskLineRenderer.swift
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(
View NestedClosureWeakSelf.swift
class Cell {
private let viewBlock: () -> Void
init(viewBlock: @escaping () -> Void) {
self.viewBlock = viewBlock
}
deinit {
print(type(of: self), #function)
}
@devxoul
devxoul / PULL_REQUEST_TEMPLATE.md
Created Sep 27, 2019
StyleShare Pull Request Template
View PULL_REQUEST_TEMPLATE.md

배경

작업 내용

테스트 방법

리뷰 노트

View Date+ISO8601.swift
//
// Date+ISO8601.swift
// SSFoundation
//
// Created by Suyeol Jeon on 19/09/2019.
// Copyright © 2019 StyleShare Inc. All rights reserved.
//
import Foundation
View HashableExample.swift
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) {
View RxSwiftRetainCount.swift
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!!!")
}
You can’t perform that action at this time.