Forget the struggle of having to manually parse Strings to Ints, Doubles and other data types!
Using the power of Codable
, WrappedValue
will automatically decode them for you, with some life-changing error handling.
typealias WrappedInt = WrappedValue<Int>
struct Person: Codable {
let age: WrappedInt
let name: String
}
If your JSON API returns age as String
"30", WrappedValue
will handle the parsing of it to an Int
as specified in the typealias
Access the Int
through person.age.value
.
In addition to Codable
, WrappedValue
also conforms to Hashable
, Equatable
and Numeric
The Example project was built and tested using Travis CI.
To run the example project, clone the repo, and run pod install
from the Example directory first.
WrappedValue is compiled using Swift 5.0 in Xcode 10.2. The project is compatible with Swift 4.2 and Swift 5.0
WrappedValue is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'WrappedValue'
cmtrounce, ctrounce94@gmail.com
WrappedValue is available under the MIT license. See the LICENSE file for more info.