Skip to content

Instantly share code, notes, and snippets.

View kuotinyen's full-sized avatar
🐛
feeds me

TK kuotinyen

🐛
feeds me
View GitHub Profile
@kuotinyen
kuotinyen / UIApplication+TopVC.md
Last active December 21, 2018 09:43
Find top viewController on window.

Usage

guard let view = topVC?.view else { return }

Extension

extension UIApplication {
    
    var topVC: UIViewController? {
@kuotinyen
kuotinyen / Reusable+Cell.md
Last active December 21, 2018 09:44
simplify tableView / CollectionView Cell registration.

Usage

tableView.registerReusableCell(ShowJobTitleInfoCell.self)

Extension

protocol Reusable: class {
    static var reuseIdentifier: String { get }
    static var nib: UINib? { get }
@kuotinyen
kuotinyen / NotificationCenter+RxEnum.md
Last active December 21, 2018 09:46
Transform notification event to RxSwift observable sequence.

Usage

NotificationCenter.default.rx
            .notification(custom: .gotFcmToken)
            .subscribe(onNext: { (value) in
                // do something
            })
            .disposed(by: bag)
@kuotinyen
kuotinyen / NotificationCenter+Enum.md
Last active December 21, 2018 09:47
Add custom notification using enum way.

Usage

NotificationCenter.post(customeNotification: .gotFcmToken)

Extension

enum Noti: String {
    case gotFcmToken
 
@kuotinyen
kuotinyen / UserDefaults+Enum.md
Last active December 21, 2018 09:48
Add custom userDefaults key using enum.

Usage

DB[.fcmToken] = fcmToken

guard let fcmToken = DB[.fcmToken] as? String 
else { return "" }

Extension

@kuotinyen
kuotinyen / UIColor+Hex.md
Last active December 21, 2018 09:50
Add UIColor hex-init way.

Usage

static var color = UIColor(rgb: 0x2e3550)

Extension

extension UIColor {
    convenience init(rgb: UInt) {
 self.init(
@kuotinyen
kuotinyen / String+UrlEncoded.md
Last active December 21, 2018 09:51
transform string to url-encoded string.

Usage

string.urlEncoded

Extension

extension String {
    var urlEncoded: String? {
 return self.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)