Skip to content

Instantly share code, notes, and snippets.

View highthem's full-sized avatar
😅

Haithem BH highthem

😅
View GitHub Profile
@highthem
highthem / CodableProtocol.playground
Created August 28, 2019 09:08
how to encode and decode a protocol
import Foundation
protocol Poi: Codable {
var type: PoiType { get }
}
enum PoiType: String, Codable {
case meter, signage
var metatype: Poi.Type {
@highthem
highthem / Assets.swift
Created August 28, 2019 09:12
how to use exported style from Paint Code
//
// Assets.swift
// Hello
//
// Created by Haithem on 28/08/2019.
// Copyright © 2019 highthem. All rights reserved.
//
// Generated by PaintCode
// http://www.paintcodeapp.com
//
@highthem
highthem / UIControlAction.swift
Created August 31, 2019 20:38
good bye addTarget with #selector and @objc methods :)
extension UIControl {
/// Typealias for UIControl closure.
public typealias UIControlTargetClosure = (UIControl) -> ()
private class UIControlClosureWrapper: NSObject {
let closure: UIControlTargetClosure
init(_ closure: @escaping UIControlTargetClosure) {
self.closure = closure
}
extension UserDefaults {
var userID: String? {
get {
return string(forKey: #function)
}
set {
set(newValue, forKey: #function)
}
}
}