remvoe explicit unwrapping

This commit is contained in:
Kevin G Christiano 2020-01-24 10:58:03 -05:00
parent af7e813e18
commit 851d5b57ff
2 changed files with 32 additions and 32 deletions

View File

@ -40,7 +40,9 @@ import UIKit
for moleculeList in molecules {
var json1d = [[AnyHashable: Any]]()
for molecule in moleculeList {
json1d.append((molecule as? ListItemModel)!.toJSON()!)
if let moleculeDictionary = (molecule as? ListItemModel)?.toJSON() {
json1d.append(moleculeDictionary)
}
}
json2d.append(json1d)
}

View File

@ -151,11 +151,9 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
var tmpMolecules = [ListItemModelProtocol]()
molecules.forEach { molecule in
let data = try? JSONSerialization.data(withJSONObject: molecule)
let listItemModel = try? JSONDecoder().decode(ListItemModel.self, from: data!)
 let jsonData = try? JSONSerialization.jsonObject(with: data!, options: .allowFragments)
let json = String(data: data!, encoding: String.Encoding.utf8)
tmpMolecules.append(listItemModel!)
if let data = try? JSONSerialization.data(withJSONObject: molecule), let listItemModel = try? JSONDecoder().decode(ListItemModel.self, from: data) {
tmpMolecules.append(listItemModel)
}
}
DispatchQueue.main.async {
@ -180,9 +178,9 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
var tmpMolecules = [ListItemModelProtocol]()
molecules.forEach { molecule in
let data = try? JSONSerialization.data(withJSONObject: molecule)
let listItemModel = try? JSONDecoder().decode(ListItemModel.self, from: data!)
tmpMolecules.append(listItemModel!)
if let data = try? JSONSerialization.data(withJSONObject: molecule), let listItemModel = try? JSONDecoder().decode(ListItemModel.self, from: data) {
tmpMolecules.append(listItemModel)
}
}
var indexPaths: [IndexPath] = []