This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct DictionaryToArrayTransform<T: Mappable>: TransformType { | |
| init() {} | |
| func transformFromJSON(_ value: Any?) -> [T]? { | |
| guard let object = value as? [String: Any] else { | |
| return nil | |
| } | |
| if let mapped = T(JSON: object) { | |
| return [mapped] | |
| } else { | |
| return [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SuperViewController: UIViewController { | |
| typealias VoidClosure = () -> Void | |
| private var onViewDidLoad: [VoidClosure] = [] | |
| // public | |
| func addOnViewdidLoad(block: @escaping VoidClosure) { | |
| if isViewLoaded { | |
| block() | |
| } else { | |
| self.onViewDidLoad.append(block) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let view = UIView().with {$0.backgroundColor = .red}.with({$0.alpha = 0.3}) | |
| extension UIView { | |
| func with(_ process: (UIView) -> ()) -> UIView { | |
| process(self) | |
| return self | |
| } | |
| } |
OlderNewer