View Loader.swift
This file contains 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
protocol Loadable { | |
var activityIndicator: UIActivityIndicatorView {get} | |
func showLoaderView() | |
func hideLoaderView() | |
} | |
extension Loadable where Self: UIViewController { | |
func showLoaderView() { | |
activityIndicator.translatesAutoresizingMaskIntoConstraints = false |
View sg_flatMap.swift
This file contains 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
extension Array { | |
func sg_flatMap<U>(transform: (Generator.Element) -> [U]) -> [U] { | |
var result = [U]() | |
for item in self { | |
result.appendContentsOf(transform(item)) | |
} | |
return result | |
} |
View simpleMapArray.swift
This file contains 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
extension Array { | |
func map<U>(transform: (element: Generator.Element) -> U) -> [U]{ | |
var elements = [U]() | |
for item in self { | |
elements.append(transform(element: item)) | |
} | |
return elements | |
} | |
} |