(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| extension NSTimer { | |
| /** | |
| Creates and schedules a one-time `NSTimer` instance. | |
| - Parameters: | |
| - delay: The delay before execution. | |
| - handler: A closure to execute after `delay`. | |
| - Returns: The newly-created `NSTimer` instance. | |
| */ |
| public protocol MeasurementUnit { | |
| // If we have one of this unit, how many millimeters is it? | |
| class var asMillimeters: Double { get } | |
| } | |
| public class Inch : MeasurementUnit { | |
| public class var asMillimeters: Double { | |
| get { | |
| return 25.4 | |
| } | |
| } |
| // based on : http://stackoverflow.com/questions/24752627/accessing-ios-address-book-with-swift-array-count-of-zero | |
| // http://stackoverflow.com/questions/24752627/accessing-ios-address-book-with-swift-array-count-of-zero | |
| class func extractABAddressBookRef(abRef: Unmanaged<ABAddressBookRef>!) -> ABAddressBookRef? { | |
| if let ab = abRef { | |
| return Unmanaged<NSObject>.fromOpaque(ab.toOpaque()).takeUnretainedValue() | |
| } | |
| return nil | |
| } |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| extension Array { | |
| func first() -> Element? { | |
| if isEmpty { | |
| return nil | |
| } | |
| return self[0] | |
| } | |
| func last() -> Element? { |