Skip to content

Instantly share code, notes, and snippets.

✏️
Studying

SeongHo Hong cozzin

✏️
Studying
Block or report user

Report or block cozzin

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 CachedClassifier.swift
class CachedClassifier {
private var sumCache = [Int: Int]()
func sumOfFactors(_ number: Int) -> Int {
if let cachedValue = sumCache[number] {
return cachedValue
}
let sum = aliquotSum(factors(number))
View EscapingClousureTest.swift
//: Playground - noun: a place where people can play
import UIKit
class TestClass {
deinit {
print("deinit \(self)")
}
@cozzin
cozzin / HeaderFooterViewHeight.swift
Last active Aug 9, 2018
여러 UI 컴포넌트들이 있는 HeaderView의 높이 계산해주기
View HeaderFooterViewHeight.swift
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
guard let headerView = headerView(at: section) else {
return nil
}
return headerView.systemLayoutSizeFitting(CGSize(width: targetView.frame.width, height: CGFloat.greatestFiniteMagnitude), withHorizontalFittingPriority: .required, verticalFittingPriority: .fittingSizeLevel).height
}
@cozzin
cozzin / Emptiable+Extension.swift
Created Aug 8, 2018
check isNotEmpty isNotNilNotEmpty
View Emptiable+Extension.swift
//
// Emptiable+Extension.swift
// sieum
//
// Created by 홍성호 on 2018. 8. 8..
// Copyright © 2018년 홍성호. All rights reserved.
//
// https://github.com/artsy/Emergence/blob/master/Emergence/Extensions/Apple/Occupyable%2BisNotEmpty.swift
//
View SHSideMenu.podspec
Pod::Spec.new do |s|
s.name = "SHSideMenu"
s.version = "0.0.4"
s.summary = "Simple side menu view controller 🍔"
s.description = <<-DESC
Simple side menu view controller for ios 🍔
DESC
s.homepage = "https://github.com/cozzin/SHSideMenu"
s.license = "MIT"
View SideMenuViewController.swift
//
// SideMenuViewController.swift
// sieum
//
// Created by 홍성호 on 2018. 6. 26..
// Copyright © 2018년 홍성호. All rights reserved.
//
import UIKit
import SnapKit
View SwiftExtensionForObjc.swift
@objc protocol AAA {
}
extension AAA {
var aa: Int {
return 0
}
}
View formatByteCount.swift
func formatByteCount(bytes: Int64) -> String {
let byteCountFormatter = ByteCountFormatter()
return byteCountFormatter.string(fromByteCount: bytes)
}
@cozzin
cozzin / RxTableView.swift
Last active Aug 19, 2018
How to cache height values ​​through delegate when using rxdatasoruce
View RxTableView.swift
class ViewController: UIViewController {
private var cellHeightsDictionary: [String: CGFloat] = [:]
override func viewDidLoad() {
super.viewDidLoad()
// set table view ...
tableView.rx.setDelegate(self).disposed(by: disposeBag)
}
View ReloadDataAndKeepOffset.swift
extension UITableView {
func reloadDataAndKeepOffset() {
let offset = contentOffset
reloadData()
layoutIfNeeded()
setContentOffset(offset, animated: false)
}
}
You can’t perform that action at this time.