remvoe explicit unwrapping
This commit is contained in:
parent
af7e813e18
commit
851d5b57ff
@ -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)
|
||||
}
|
||||
|
||||
@ -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] = []
|
||||
|
||||
Loading…
Reference in New Issue
Block a user