Skip to content

Instantly share code, notes, and snippets.

View dagad's full-sized avatar
🕶️
Early Bird

SanGyeol Kang dagad

🕶️
Early Bird
View GitHub Profile
@dagad
dagad / UITextViewPlaceholder.swift
Created May 11, 2022 08:29 — forked from tijme/UITextViewPlaceholder.swift
The correct way to implement a placeholder in a UITextView (Swift)
//
// UITextViewPlaceholder.swift
// TextViewPlaceholder
//
// Copyright (c) 2017 Tijme Gommers <tijme@finnwea.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@dagad
dagad / podforceupdate.sh
Created December 27, 2019 04:46 — forked from mbinna/podforceupdate.sh
Clear CocoaPods cache, re-download and re-install all pods
#!/usr/bin/env bash
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
@dagad
dagad / ProvisioningPath.txt
Created April 25, 2019 09:16
Provisioning Path
~/Library/MobileDevice/Provisioning Profiles/
@dagad
dagad / ioslocaleidentifiers.csv
Created April 23, 2019 01:57 — forked from jacobbubu/ioslocaleidentifiers.csv
iOS Locale Identifiers
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
mr Marathi
bs Bosnian
ee_TG Ewe (Togo)
ms Malay
kam_KE Kamba (Kenya)
mt Maltese
ha Hausa
es_HN Spanish (Honduras)
ml_IN Malayalam (India)
ro_MD Romanian (Moldova)
@dagad
dagad / Delegated.swift
Created April 19, 2019 03:58
Advanced approach to use self in closure
struct Delegated<Input> {
private(set) var callback: ((Input) -> Void)?
mutating func delegate<Object : AnyObject>(to object: Object, with callback: @escaping (Object, Input) -> Void) {
self.callback = { [weak object] input in
guard let object = object else {
return
}
callback(object, input)
@dagad
dagad / ObservableStore.swift
Created April 2, 2019 23:03 — forked from agentk/ObservableStore.swift
ReSwift Store and ViewModel Scaffolding
import ReSwift
import ReactiveKit
class ObservableStore<State: StateType>: Store<State> {
let observable: Observable<State>
var reducer: AnyReducer!
override var state: State! {
didSet {
@dagad
dagad / ObservableStore.swift
Created April 2, 2019 23:03 — forked from agentk/ObservableStore.swift
ReSwift Store and ViewModel Scaffolding
import ReSwift
import ReactiveKit
class ObservableStore<State: StateType>: Store<State> {
let observable: Observable<State>
var reducer: AnyReducer!
override var state: State! {
didSet {
class MockUserDefaults: UserDefaults {
convenience init() {
self.init(suiteName: "MockUserDefaults")!
}
override init?(suiteName suitename: String?) {
UserDefaults().removePersistentDomain(forName: suitename!)
super.init(suiteName: suitename)
}
}
@dagad
dagad / UICollectionView+register.swift
Created April 1, 2019 01:46
same as UITableView+register
extension UICollectionView {
func register<T: UICollectionViewCell>(_: T.Type) where T: Reusable & NibLoadable {
let nib = UINib(nibName: T.nibName, bundle: nil)
register(nib, forCellWithReuseIdentifier: T.reuseIdentifier)
}
func registerSupplementaryView<T: UICollectionReusableView>(_: T.Type, for kind: String) where T: Reusable, T: NibLoadable {
let nib = UINib(nibName: T.nibName, bundle: nil)
register(nib, forSupplementaryViewOfKind: kind, withReuseIdentifier: T.reuseIdentifier)
}
@dagad
dagad / UITableView+register.swift
Last active April 1, 2019 01:45
UITableView+register
protocol Reusable: class {}
extension Reusable where Self: UIView {
static var reuseIdentifier: String {
return String(describing: self)
}
}
protocol NibLoadable: class { }