Skip to content

Instantly share code, notes, and snippets.

Samir Guerdah samirGuerdah

View GitHub Profile
View Loader.swift
protocol Loadable {
var activityIndicator: UIActivityIndicatorView {get}
func showLoaderView()
func hideLoaderView()
extension Loadable where Self: UIViewController {
func showLoaderView() {
activityIndicator.translatesAutoresizingMaskIntoConstraints = false
samirGuerdah / sg_flatMap.swift
Created Apr 17, 2016
Sample flatMap function as extension in Array
View sg_flatMap.swift
extension Array {
func sg_flatMap<U>(transform: (Generator.Element) -> [U]) -> [U] {
var result = [U]()
for item in self {
return result
View simpleMapArray.swift
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
You can’t perform that action at this time.