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
class Utilities { | |
class func subviewsOfView(view: UIView, withType type: String) -> [UIView] | |
{ | |
let prefix = "<\(type)" | |
var subviewArray = view.subviews.flatMap { subview in subviewsOfView(subview, withType: type) } | |
if view.description.hasPrefix(prefix) { | |
subviewArray.append(view) | |
} | |
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
// MARK: - Swizzling | |
extension UIFont { | |
class var defaultFontFamily: String { return "Georgia" } | |
override public class func initialize() | |
{ | |
if self == UIFont.self { | |
swizzleSystemFont() | |
} | |
} |
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
struct Regex { | |
let pattern: String | |
let options: NSRegularExpressionOptions | |
private var matcher: NSRegularExpression { | |
return try! NSRegularExpression(pattern: pattern, options: options) | |
} | |
init(pattern: String, options: NSRegularExpressionOptions! = nil) | |
{ |
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
func weak<Object: AnyObject>(_ object: Object, block: @escaping (Object) -> Void) -> () -> Void { | |
return { [weak object] in | |
guard let object = object else { return } | |
block(object) | |
} | |
} | |
func weak<Object: AnyObject, Input>(_ object: Object, block: @escaping (Object, Input) -> Void) -> (Input) -> Void { | |
return { [weak object] in | |
guard let object = object else { return } |
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 UIView { | |
@IBInspectable var borderColor: UIColor? { | |
get { return layer.borderColor.map(UIColor.init) } | |
set { layer.borderColor = newValue?.CGColor } | |
} | |
@IBInspectable var borderWidth: CGFloat { | |
get { return layer.borderWidth } | |
set { layer.borderWidth = newValue } | |
} | |
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
import Foundation | |
struct Person { | |
var firstName: String | |
var lastName: String | |
var age: Int | |
} | |
extension Person { | |
enum Query { |
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
import UIKit | |
// MARK: - Building Blocks | |
struct Screen<A> { | |
let run: (A -> Void) -> UIViewController | |
} | |
extension Screen { | |
func map<B>(f: A -> B) -> Screen<B> | |
{ |
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
override func spec() | |
{ | |
var subject: UIViewController!, viewModel: ViewModel! | |
beforeEach { (subject, viewModel) = self.newSubject } | |
context("once the view has loaded") { | |
beforeEach { subject.loadViewIfNeeded() } | |
describe("events sent to view model") { | |
context("when selection changes") { |
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
tableView.register(StoryCell.self, forCellReuseIdentifier: "StoryCell") | |
let cell = tableView.dequeueReusableCell(withIdentifier: "StoryCell", for: indexPath) as? StoryCell |
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
tableView.register(forReuse: StoryCell.self) | |
let cell = tableView.dequeueReusable(StoryCell.self, for: indexPath) |
NewerOlder