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 / 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)
@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 / 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 / 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 / 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 / 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 / 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 / UIViewController+Base.md
Created December 21, 2018 09:55
a base viewController for setup views.

Extension

class BaseVC: UIViewController {

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
    }
 
@kuotinyen
kuotinyen / UITableViewCell+Base.md
Created December 21, 2018 09:56
a base tableView cell for setup views.
class BaseTableViewCell: UITableViewCell {
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupViews()
    }
    
    required init?(coder aDecoder: NSCoder) {
 fatalError("init(coder:) has not been implemented")
@kuotinyen
kuotinyen / MapGuideAction.md
Created December 21, 2018 10:22
launch iOS system map app to guide location.

Usage

MapGuideManager.guide(from: nil, to:job.gps.location, with: job.companyName)

Extension

class MapGuideManager {
    class func guide(from startPoint: CLLocationCoordinate2D? = nil, to destination: CLLocationCoordinate2D? = nil, with destinationTitle: String) {