Created
December 25, 2014 17:09
-
-
Save ChristianKienle/0a612d6869553c812faa to your computer and use it in GitHub Desktop.
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 | |
| public struct Row { | |
| private let valuesByColumnNames = [String: Bindable]() | |
| internal init(valuesByColumnNames:[String: Bindable]) { | |
| self.valuesByColumnNames = valuesByColumnNames | |
| } | |
| } | |
| // General | |
| extension Row { | |
| public var allColumnNames:[String] { | |
| return Array(self.valuesByColumnNames.keys) | |
| } | |
| } | |
| // Extracting Values | |
| extension Row { | |
| public func stringValue(columnName:String) -> String? { | |
| return value(columnName) | |
| } | |
| public func intValue(columnName:String) -> Int? { | |
| return value(columnName) | |
| } | |
| public func doubleValue(columnName:String) -> Double? { | |
| return value(columnName) | |
| } | |
| private func value<T>(columnName:String) -> T? { | |
| return self.valuesByColumnNames[columnName] as? T | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment