Add Codable conformance to common Foundation types

Add conformances + unit tests for

* CGFloat
* AffineTransform
* Calendar
* CharacterSet
* DateComponents
* DateInterval
* Decimal
* IndexPath
* IndexSet
* Locale
* Measurement
* NSRange
* PersonNameComponents
* TimeZone
* URL
* UUID

along with some unit tests for each.
This commit is contained in:
Itai Ferber
2017-05-17 16:01:20 -07:00
parent f49808eb0b
commit 012ea9373b
22 changed files with 1135 additions and 113 deletions

View File

@@ -172,3 +172,17 @@ extension NSRange : CustomPlaygroundQuickLookable {
}
}
extension NSRange : Codable {
public init(from decoder: Decoder) throws {
var container = try decoder.unkeyedContainer()
let location = try container.decode(Int.self)
let length = try container.decode(Int.self)
self.init(location: location, length: length)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.unkeyedContainer()
try container.encode(self.location)
try container.encode(self.length)
}
}