Releases: ovenbits/ModelRocket
Releases · ovenbits/ModelRocket
ModelRocket 1.3
ModelRocket 1.2.4
Added
- RawRepresentable conformance to
JSON
- This includes a failable initializer with a single AnyObject argument and a compute property named
rawValue
of type AnyObject
- This includes a failable initializer with a single AnyObject argument and a compute property named
- Function for converting a
JSON
object back to raw NSData
do {
let data = try json.rawData(.PrettyPrinted)
// do something with data
}
catch let error = JSON.DataError {}
catch {}
ModelRocket 1.2.3
Added
- Swift Package Manager support!
ModelRocket 1.2.2
Updated
- Built-in date formatter to accept non-GMT date formats. ISO8601 formatting (
yyyy-MM-dd'T'HH:mm:ss.SSSZ
) is still required, but a future release will contain support for more formats. In the meantime, you can use this pattern if your models require a different format:
private let dateFormatter = {
let formatter = NSDateFormatter()
formatter.format = "yyyy-MM-dd"
return formatter
}()
private let _date = Property<String>(key: "date")
public var date: NSDate? {
guard let date = _date.value else { return nil }
return dateFormatter.dateFromString(date)
}
Fixed
- Issue where time zones weren't respected while parsing JSON to/from NSDate objects
ModelRocket 1.2.1
Fixed
- An issue with the default implementation of
fromJSON
forModel
types. The implementation worked without issue in simulator builds, but caused crashing on device builds. Attempting to access thedynamicType
onSelf
currently causes problems on device builds, sodynamicType
is no longer used; however,fromJSON
can still be overridden in the subclass if needed.
Updated
- The convenience initializers on
Model
are now designated initializers. This allows these initializers to be overridden in subclasses.
ModelRocket 1.2
Added
hasValue
andhasKey
toJSON
(replacesisNil
). The behavior ofisNil
was not always clear, in cases where the JSON contained a valid key but a null value.hasValue
andhasKey
clears this up.
let json: JSON = [
"string" : NSNull()
]
json["string"].hasValue // false
json["string"].hasKey // true
Fixed
- Issue where subclassing a
Model
subclass resulted in broken JSONTransformable conformance.
let json: JSON = [
"cars" : [
[
"model" : "BMW",
"year" : 2015,
"number_of_doors" : 4
]
]
]
class Vehicle: Model, JSONTransformable {
let model = Property<String>(key: "model")
let year = Property<Int>(key: "year")
}
class Car: Vehicle {
let numberOfDoors = Property<Int>(key: "number_of_doors")
}
class Garage: Model {
let cars = PropertyArray<Car>(key: "cars")
}
let garage = Garage(json: json)
// previously
garage.cars.first // nil
// now
garage.cars.first // valid Car object
ModelRocket 1.1 with Swift 2 support
Added
- Swift 2 support!
- Default implementations for
Model
andRawRepresentable
(String and Int) types. isNil
property onJSON
Updated
- Conformance to Equatable for
JSON
,Property
,PropertyArray
, andPropertyDictionary
Renamed
ModelRocket
class toModel
, to fix a namespacing issue caused by the framework and class sharing the same name.