- ObjectMapper can now be implemented within an extension using the
StaticMappable
protocol. (Thanks @andrebraga)
Below is the new protocol structure
/// BaseMappable should not be implemented directly. Mappable or StaticMappable should be used instead
public protocol BaseMappable {
/// This function is where all variable mappings should occur. It is executed by Mapper during the mapping (serialization and deserialization) process.
mutating func mapping(map: Map)
}
public protocol Mappable: BaseMappable {
/// This function can be used to validate JSON prior to mapping. Return nil to cancel mapping at this point
init?(_ map: Map)
}
public protocol StaticMappable: BaseMappable {
/// This function should return an instance of BaseMappable that ObjectMapper will use for mapping. It can also be used to:
/// 1) provide an existing cached object to be used for mapping
/// 2) return an object of another class (which conforms to Mappable) to be used for mapping. For instance, you may inspect the JSON to infer the type of object that should be used for any given mapping
/// 3) perform validation prior to mapping
static func objectForMapping(map: Map) -> BaseMappable?
}
- Compilation speed improvements (@ivanbruel)
- NSDataTransform