Skip to content

Instantly share code, notes, and snippets.

View ilyapuchka's full-sized avatar

Ilya Puchka ilyapuchka

View GitHub Profile
@ilyapuchka
ilyapuchka / Extensions.swift
Last active October 29, 2015 11:44
Swift extensions for classes and structs
protocol ProtocolA {}
protocol ProtocolB: ProtocolA {}
protocol ProtocolC {
func act()
}
protocol ProtocolD {
typealias V
func act()
}
@ilyapuchka
ilyapuchka / gist:fcb4c50ca5fb49ecc072
Last active August 29, 2015 14:25
Guess what it does
func z_map<S : SequenceType, T>(source: S, transform: (S.Generator.Element) -> T?) -> [T] {
// easy, right? =)
return reduce(source, []) { r, i in map( transform(i) ) { r + [$0] } ?? r }
}
@ilyapuchka
ilyapuchka / gist:1ae19259161a91f3a8a8
Created March 16, 2015 21:32
Swift Playgrounds & iOS Simulator
import UIKit
struct MainScene {
let vc: UIViewController
let nc: UINavigationController
init(vc: UIViewController) {
self.vc = vc
self.nc = UINavigationController(rootViewController: vc)
}
}
protocol HasTitle {
var ht_title: String {get set}
}
extension UIBarButtonItem: HasTitle {
var ht_title: String {
get {
return self.title ?? ""
}
set {