remove unused code

This commit is contained in:
Pfeil, Scott Robert 2019-12-18 13:14:56 -05:00
parent fc108373cb
commit e1ecb35531

View File

@ -80,27 +80,20 @@ extension KeyedDecodingContainer where Key: CodingKey {
var models = [Model]() var models = [Model]()
var container = try nestedUnkeyedContainer(forKey: codingKey) var container = try nestedUnkeyedContainer(forKey: codingKey)
var containerCopy = container var containerCopy = container
var i = 0
let count = container.count ?? 0
while !container.isAtEnd { while !container.isAtEnd {
if i < count { let nestedContainer = try container.nestedContainer(keyedBy: C.self)
let nestedContainer = try container.nestedContainer(keyedBy: C.self) if let identifier = try nestedContainer.decodeIfPresent(String.self, forKey: typeCodingKey) {
if let identifier = try nestedContainer.decodeIfPresent(String.self, forKey: typeCodingKey) { //get the type
//get the type guard let type = ModelRegistry.types[identifier] else {
guard let type = ModelRegistry.types[identifier] else { throw ModelRegistry.Error.decoderErrorModelNotMapped
throw ModelRegistry.Error.decoderErrorModelNotMapped
}
//now get the decoder to use for the type
let decoder = try containerCopy.superDecoder()
let model = try type.init(from: decoder)
models.append(model)
} }
i+=1 //now get the decoder to use for the type
let decoder = try containerCopy.superDecoder()
let model = try type.init(from: decoder)
models.append(model)
} }
} }
return models.count > 0 ? models : nil return models
} }
/// Decodes an array of registered model based on the identifiers. /// Decodes an array of registered model based on the identifiers.