This file contains hidden or 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 Character { | |
| public static var newlineCharacterSet: Set<Character> { | |
| return ["\u{000A}", "\u{000B}", "\u{000C}", "\u{000D}", "\u{0085}"] | |
| } | |
| public static var whiteSpaceCharacterSet: Set<Character> { | |
| return ["\u{0020}", "\u{0009}"] | |
| } | |
| public static var whiteSpaceAndNewlineCharacterSet: Set<Character> { |
This file contains hidden or 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 Deferrable { | |
| let closure: ()->Void | |
| init(closure: ()->Void) { | |
| self.closure = closure | |
| } | |
| deinit { | |
| closure() | |
| } |
This file contains hidden or 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 | |
| func +(lhs: NSURL, rhs:String) -> NSURL { | |
| return lhs.URLByAppendingPathComponent(rhs) | |
| } | |
| let url = NSURL(string: "http://google.com")! | |
| url | |
| url + "pages" |
This file contains hidden or 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 foo(a: Int, what b: Int, _ name: String) -> Void { | |
| print(a) | |
| print(b) | |
| print(name) | |
| } | |
| let arguments = (4, what: 3, "hello") | |
| foo(arguments) |
This file contains hidden or 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 NodeImpl { | |
| var node: Node? | |
| func copy() -> NodeImpl { | |
| let copy = NodeImpl() | |
| copy.node = node | |
| return copy | |
| } | |
| } |
This file contains hidden or 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
| // fill in the blanks with mismatched lhs and rhs types | |
| func +(lhs: Int, rhs: Double) -> Double { | |
| return Double(lhs) + rhs | |
| } | |
| func +(lhs: Double, rhs: Int) -> Double { | |
| return lhs + Double(rhs) | |
| } | |
| func +(lhs: Int, rhs: Float) -> Float { |
This file contains hidden or 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 | |
| class NotificationManager | |
| { | |
| static let sharedManager = NotificationManager() | |
| var observersMap = [String:NSHashTable]() | |
| func add<T>(type: T.Type, observer: T) { | |
| let typeString = "\(T.self)" | |
| let observers: NSHashTable |
This file contains hidden or 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 ImagePreheatingController { | |
| public var rx_delegate: DelegateProxy { | |
| return proxyForObject(RxImagePreheatingControllerDelegateProxy.self, self) | |
| } | |
| public var rx_preheatItems: Observable<([Int], [Int])> { | |
| return rx_delegate.observe("preheatingController:didUpdateWithAddedIndexPaths:removedIndexPaths:") | |
| .map { a in | |
| print(a) | |
| return ([], []) |
This file contains hidden or 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 | |
| class SingleCellTableView<Cell>: UITableView { | |
| override init(frame: CGRect, style: UITableViewStyle) { | |
| super.init(frame: frame, style: style) | |
| registerCell() | |
| } | |
| func registerCell() { | |
| guard let cellClass = Cell.self as? AnyClass else { |
This file contains hidden or 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 Range where Bound: Int { | |
| func random() -> Int { | |
| return min + Int(arc4random_uniform(UInt32(upperBound - lowerBound))) | |
| } | |
| } |
OlderNewer