Skip to content

Releases: ovenbits/ModelRocket

ModelRocket 1.3

04 Apr 03:54
Compare
Choose a tag to compare

Added

  • Swift 2.2 support!

ModelRocket 1.2.4

13 Feb 05:03
Compare
Choose a tag to compare

Added

  • RawRepresentable conformance to JSON
    • This includes a failable initializer with a single AnyObject argument and a compute property named rawValue of type AnyObject
  • 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

20 Jan 03:38
Compare
Choose a tag to compare

Added

  • Swift Package Manager support!

ModelRocket 1.2.2

18 Nov 04:57
Compare
Choose a tag to compare

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

29 Oct 21:35
Compare
Choose a tag to compare

Fixed

  • An issue with the default implementation of fromJSON for Model types. The implementation worked without issue in simulator builds, but caused crashing on device builds. Attempting to access the dynamicType on Self currently causes problems on device builds, so dynamicType 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

27 Oct 02:52
Compare
Choose a tag to compare

Added

  • hasValue and hasKey to JSON (replaces isNil). The behavior of isNil was not always clear, in cases where the JSON contained a valid key but a null value. hasValue and hasKey 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

17 Sep 03:05
Compare
Choose a tag to compare

Added

  • Swift 2 support!
  • Default implementations for Model and RawRepresentable (String and Int) types.
  • isNil property on JSON

Updated

  • Conformance to Equatable for JSON, Property, PropertyArray, and PropertyDictionary

Renamed

  • ModelRocket class to Model, to fix a namespacing issue caused by the framework and class sharing the same name.

1.0

25 Aug 15:43
Compare
Choose a tag to compare
1.0
Initial commit