remove unused code
This commit is contained in:
parent
fc108373cb
commit
e1ecb35531
@ -80,27 +80,20 @@ extension KeyedDecodingContainer where Key: CodingKey {
|
||||
var models = [Model]()
|
||||
var container = try nestedUnkeyedContainer(forKey: codingKey)
|
||||
var containerCopy = container
|
||||
|
||||
var i = 0
|
||||
let count = container.count ?? 0
|
||||
|
||||
while !container.isAtEnd {
|
||||
if i < count {
|
||||
let nestedContainer = try container.nestedContainer(keyedBy: C.self)
|
||||
if let identifier = try nestedContainer.decodeIfPresent(String.self, forKey: typeCodingKey) {
|
||||
//get the type
|
||||
guard let type = ModelRegistry.types[identifier] else {
|
||||
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)
|
||||
let nestedContainer = try container.nestedContainer(keyedBy: C.self)
|
||||
if let identifier = try nestedContainer.decodeIfPresent(String.self, forKey: typeCodingKey) {
|
||||
//get the type
|
||||
guard let type = ModelRegistry.types[identifier] else {
|
||||
throw ModelRegistry.Error.decoderErrorModelNotMapped
|
||||
}
|
||||
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.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user