From 9c8a55cc828534e18070db9ba8246d2799b14815 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 28 Jan 2020 11:54:24 -0500 Subject: [PATCH] latest and greatest --- .../JSONCreator.xcodeproj/project.pbxproj | 4 ++++ JSONCreator_iOS/JSONCreator/AtomicAPI.swift | 19 +++++++++++++++++++ .../JSONCreator/MasterViewController.swift | 9 +++++---- 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 JSONCreator_iOS/JSONCreator/AtomicAPI.swift diff --git a/JSONCreator_iOS/JSONCreator.xcodeproj/project.pbxproj b/JSONCreator_iOS/JSONCreator.xcodeproj/project.pbxproj index 3e3db4d..25622fa 100644 --- a/JSONCreator_iOS/JSONCreator.xcodeproj/project.pbxproj +++ b/JSONCreator_iOS/JSONCreator.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 0A5DD26123E0831500B3B076 /* AtomicAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5DD26023E0831500B3B076 /* AtomicAPI.swift */; }; 0AA7BDD2230DA06D00EED90B /* MolecularModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA7BDD1230DA06D00EED90B /* MolecularModel.swift */; }; 0ADD8082231055F500A5E643 /* ObjectParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ADD8081231055F500A5E643 /* ObjectParser.swift */; }; 0ADD8086231056FF00A5E643 /* ObjectCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ADD8085231056FF00A5E643 /* ObjectCell.swift */; }; @@ -57,6 +58,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 0A5DD26023E0831500B3B076 /* AtomicAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomicAPI.swift; sourceTree = ""; }; 0AA7BDD1230DA06D00EED90B /* MolecularModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MolecularModel.swift; sourceTree = ""; }; 0ADD8081231055F500A5E643 /* ObjectParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectParser.swift; sourceTree = ""; }; 0ADD8085231056FF00A5E643 /* ObjectCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectCell.swift; sourceTree = ""; }; @@ -137,6 +139,7 @@ D2B1E40922F4C9F00065F95C /* JSON */, D2B1E3FD22F4A6930065F95C /* LaunchScreen.storyboard */, D2B1E40022F4A6930065F95C /* Info.plist */, + 0A5DD26023E0831500B3B076 /* AtomicAPI.swift */, ); path = JSONCreator; sourceTree = ""; @@ -251,6 +254,7 @@ buildActionMask = 2147483647; files = ( 0AA7BDD2230DA06D00EED90B /* MolecularModel.swift in Sources */, + 0A5DD26123E0831500B3B076 /* AtomicAPI.swift in Sources */, 0ADD80882310570A00A5E643 /* ArrayCell.swift in Sources */, D2B1E3F722F4A68F0065F95C /* DetailViewController.swift in Sources */, 0ADD8086231056FF00A5E643 /* ObjectCell.swift in Sources */, diff --git a/JSONCreator_iOS/JSONCreator/AtomicAPI.swift b/JSONCreator_iOS/JSONCreator/AtomicAPI.swift new file mode 100644 index 0000000..e5b5f5c --- /dev/null +++ b/JSONCreator_iOS/JSONCreator/AtomicAPI.swift @@ -0,0 +1,19 @@ +// +// AtomicAPI.swift +// JSONCreator +// +// Created by Kevin Christiano on 1/28/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + + +class AtomicAPI { + + /// Pulls the latest state of a all stored structures in the the Atomic DB. + static func syncStructures() { + + } + +} diff --git a/JSONCreator_iOS/JSONCreator/MasterViewController.swift b/JSONCreator_iOS/JSONCreator/MasterViewController.swift index 3c9d323..4732728 100644 --- a/JSONCreator_iOS/JSONCreator/MasterViewController.swift +++ b/JSONCreator_iOS/JSONCreator/MasterViewController.swift @@ -191,14 +191,15 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa let molecularModel = MolecularModel() molecularModel.category = categoryName as! String - let jsonContent = (content as! String).data(using: .utf8) - guard let categoryContent = try JSONSerialization.jsonObject(with: jsonContent!, options: []) as? [AnyHashable: Any] else { return } + guard let jsonContent = (content as? String)?.data(using: .utf8), + let categoryContent = try JSONSerialization.jsonObject(with: jsonContent, options: []) as? [AnyHashable: Any] + else { continue } // Cycle through the molecules held by a category. for (moleculeName, moleculeValue) in categoryContent { - let moleculeJSON = (moleculeValue as! String).data(using: .utf8) - guard let moldictionaryCat = try JSONSerialization.jsonObject(with: moleculeJSON!, options: []) as? [AnyHashable: Any] else { return } + guard let moleculeJSON = (moleculeValue as? String)?.data(using: .utf8), + let moldictionaryCat = try JSONSerialization.jsonObject(with: moleculeJSON, options: []) as? [AnyHashable: Any] else { continue } molecularModel.molecules.append([moleculeName as! String: moldictionaryCat]) }