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 Double { | |
func toFloat() -> CGFloat { | |
return CGFloat(self) | |
} | |
} |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
func makeView<ViewType: UIView>(f: () -> ViewType, translatesAutoresizingMaskIntoConstraints: Bool) -> ViewType { | |
let view = f() | |
view.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints | |
return 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
extension String { | |
func toUpperCase() -> String { | |
return uppercaseString | |
} | |
} | |
extension SequenceType { | |
@warn_unused_result | |
func mapByCalling<T>(@noescape transformer: (Self.Generator.Element) throws -> (() -> T)) rethrows -> [T] { | |
return try self.map(transformer).map({ $0() }) |
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 CollectionType where Index: BidirectionalIndexType { | |
func lastIndexOf(isElement: Generator.Element -> Bool) -> Index? { | |
return indices.reverse().filter { return isElement(self[$0]) }.first | |
} | |
} |
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 MyDelegate: class { } | |
final class MyObject { | |
weak var delegate: MyDelegate? | |
} |
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 MyDelegate { } | |
final class MyObject { | |
let delegate: MyDelegate | |
init(delegate: MyDelegate) { | |
self.delegate = delegate | |
} | |
} |
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 Kennycol { | |
func kennyThang() -> String; | |
} | |
class KennyClass: Kennycol { | |
func kennyThang() -> String { | |
return "example" | |
} | |
} |