Designing logic to simply pull from custom server.
This commit is contained in:
parent
57d9899283
commit
78bded54e5
@ -21,6 +21,7 @@
|
|||||||
/* End PBXAggregateTarget section */
|
/* End PBXAggregateTarget section */
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
0AE3D04E2303009C00B844C7 /* QueryServerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE3D04D2303009C00B844C7 /* QueryServerCell.swift */; };
|
||||||
D2B1E3F322F4A68F0065F95C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B1E3F222F4A68F0065F95C /* AppDelegate.swift */; };
|
D2B1E3F322F4A68F0065F95C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B1E3F222F4A68F0065F95C /* AppDelegate.swift */; };
|
||||||
D2B1E3F522F4A68F0065F95C /* MasterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B1E3F422F4A68F0065F95C /* MasterViewController.swift */; };
|
D2B1E3F522F4A68F0065F95C /* MasterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B1E3F422F4A68F0065F95C /* MasterViewController.swift */; };
|
||||||
D2B1E3F722F4A68F0065F95C /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B1E3F622F4A68F0065F95C /* DetailViewController.swift */; };
|
D2B1E3F722F4A68F0065F95C /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B1E3F622F4A68F0065F95C /* DetailViewController.swift */; };
|
||||||
@ -53,6 +54,7 @@
|
|||||||
/* End PBXCopyFilesBuildPhase section */
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
0AE3D04D2303009C00B844C7 /* QueryServerCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QueryServerCell.swift; sourceTree = "<group>"; };
|
||||||
D2B1E3EF22F4A68F0065F95C /* JSONCreator.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JSONCreator.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
D2B1E3EF22F4A68F0065F95C /* JSONCreator.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JSONCreator.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
D2B1E3F222F4A68F0065F95C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
D2B1E3F222F4A68F0065F95C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
D2B1E3F422F4A68F0065F95C /* MasterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterViewController.swift; sourceTree = "<group>"; };
|
D2B1E3F422F4A68F0065F95C /* MasterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterViewController.swift; sourceTree = "<group>"; };
|
||||||
@ -109,6 +111,7 @@
|
|||||||
D2B1E3FB22F4A6930065F95C /* Assets.xcassets */,
|
D2B1E3FB22F4A6930065F95C /* Assets.xcassets */,
|
||||||
D2B1E3FD22F4A6930065F95C /* LaunchScreen.storyboard */,
|
D2B1E3FD22F4A6930065F95C /* LaunchScreen.storyboard */,
|
||||||
D2B1E40022F4A6930065F95C /* Info.plist */,
|
D2B1E40022F4A6930065F95C /* Info.plist */,
|
||||||
|
0AE3D04D2303009C00B844C7 /* QueryServerCell.swift */,
|
||||||
);
|
);
|
||||||
path = JSONCreator;
|
path = JSONCreator;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -223,6 +226,7 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
D2B1E3F722F4A68F0065F95C /* DetailViewController.swift in Sources */,
|
D2B1E3F722F4A68F0065F95C /* DetailViewController.swift in Sources */,
|
||||||
|
0AE3D04E2303009C00B844C7 /* QueryServerCell.swift in Sources */,
|
||||||
D2B1E3F522F4A68F0065F95C /* MasterViewController.swift in Sources */,
|
D2B1E3F522F4A68F0065F95C /* MasterViewController.swift in Sources */,
|
||||||
D2B1E3F322F4A68F0065F95C /* AppDelegate.swift in Sources */,
|
D2B1E3F322F4A68F0065F95C /* AppDelegate.swift in Sources */,
|
||||||
);
|
);
|
||||||
@ -301,7 +305,7 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
|
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
@ -356,7 +360,7 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
|
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
|
|||||||
@ -72,4 +72,3 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
import MVMCoreUI
|
import MVMCoreUI
|
||||||
|
|
||||||
|
|
||||||
class DetailViewController: UIViewController {
|
class DetailViewController: UIViewController {
|
||||||
|
|
||||||
let textView = UITextView(frame: .zero)
|
let textView = UITextView(frame: .zero)
|
||||||
|
|||||||
@ -7,47 +7,86 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import MVMCore
|
||||||
|
|
||||||
|
|
||||||
class MasterViewController: UITableViewController {
|
class MasterViewController: UITableViewController {
|
||||||
|
|
||||||
let folderPath = Bundle.main.resourcePath! + "/JSON"
|
let folderPath = Bundle.main.resourcePath! + "/JSON"
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
// Do any additional setup after loading the view.
|
// Do any additional setup after loading the view.
|
||||||
|
|
||||||
|
tableView.estimatedRowHeight = 80
|
||||||
|
tableView.rowHeight = UITableView.automaticDimension
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Table View
|
// MARK: - Table View
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
||||||
return try! FileManager.default.contentsOfDirectory(atPath: folderPath)[section]
|
return try? FileManager.default.contentsOfDirectory(atPath: folderPath)[section]
|
||||||
}
|
}
|
||||||
|
|
||||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||||
return try! FileManager.default.contentsOfDirectory(atPath: folderPath).count
|
return try! FileManager.default.contentsOfDirectory(atPath: folderPath).count
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||||
|
|
||||||
|
if section == 0 {
|
||||||
|
return try! FileManager.default.contentsOfDirectory(atPath: folderPath + "/" + FileManager.default.contentsOfDirectory(atPath: folderPath)[section]).count + 1
|
||||||
|
}
|
||||||
|
|
||||||
return try! FileManager.default.contentsOfDirectory(atPath: folderPath + "/" + FileManager.default.contentsOfDirectory(atPath: folderPath)[section]).count
|
return try! FileManager.default.contentsOfDirectory(atPath: folderPath + "/" + FileManager.default.contentsOfDirectory(atPath: folderPath)[section]).count
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||||
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
|
|
||||||
|
|
||||||
let name = try! FileManager.default.contentsOfDirectory(atPath: folderPath + "/" + FileManager.default.contentsOfDirectory(atPath: folderPath)[indexPath.section])[indexPath.row]
|
|
||||||
cell.textLabel?.text = name
|
|
||||||
|
|
||||||
if cell.interactions.first == nil {
|
|
||||||
let dragInteraction = UIDragInteraction(delegate: self)
|
if indexPath.section == 0 {
|
||||||
cell.addInteraction(dragInteraction)
|
guard let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as? QueryServerCell else { return UITableViewCell() }
|
||||||
|
cell.requestServer = requestJSON
|
||||||
|
return cell
|
||||||
|
|
||||||
|
} else {
|
||||||
|
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
|
||||||
|
|
||||||
|
let name = try! FileManager.default.contentsOfDirectory(atPath: folderPath + "/" + FileManager.default.contentsOfDirectory(atPath: folderPath)[indexPath.section])[indexPath.row]
|
||||||
|
cell.textLabel?.text = name
|
||||||
|
|
||||||
|
if cell.interactions.first == nil {
|
||||||
|
let dragInteraction = UIDragInteraction(delegate: self)
|
||||||
|
cell.addInteraction(dragInteraction)
|
||||||
|
}
|
||||||
|
return cell
|
||||||
}
|
}
|
||||||
return cell
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
|
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
|
||||||
// Return false if you do not want the specified item to be editable.
|
// Return false if you do not want the specified item to be editable.
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func requestJSON() {
|
||||||
|
|
||||||
|
let requestParameters = MVMCoreRequestParameters(actionMap: [:])
|
||||||
|
let errorLocation = (MVMCoreLoadHandler.sharedGlobal()?.errorLocation(forRequest: MVMCoreSessionTimeHandler.sharedSession(),
|
||||||
|
pageType: "test",
|
||||||
|
modules: ""))!
|
||||||
|
|
||||||
|
MVMCoreDispatchUtility.performBlock(inBackground: {
|
||||||
|
|
||||||
|
MVMCoreLoadHandler.sharedGlobal()?.sendRequest(requestParameters!, locationForError: errorLocation, requestFinished: { json, error in
|
||||||
|
|
||||||
|
if error != nil {
|
||||||
|
// BAD
|
||||||
|
} else {
|
||||||
|
// GOOD
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MasterViewController: UIDragInteractionDelegate {
|
extension MasterViewController: UIDragInteractionDelegate {
|
||||||
|
|||||||
35
JSONCreator_iOS/JSONCreator/QueryServerCell.swift
Normal file
35
JSONCreator_iOS/JSONCreator/QueryServerCell.swift
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
//
|
||||||
|
// QueryServerCell.swift
|
||||||
|
// JSONCreator
|
||||||
|
//
|
||||||
|
// Created by Kevin Christiano on 8/13/19.
|
||||||
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
|
||||||
|
class QueryServerCell: UITableViewCell {
|
||||||
|
|
||||||
|
var requestServer: (()->())?
|
||||||
|
|
||||||
|
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||||
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||||
|
|
||||||
|
let button = UIButton(frame: .zero)
|
||||||
|
button.setTitle("RequestView", for: .normal)
|
||||||
|
button.backgroundColor = .yellow
|
||||||
|
button.addTarget(self, action: #selector(requestJSON), for: .touchUpInside)
|
||||||
|
contentView.addSubview(button)
|
||||||
|
NSLayoutConstraint.pinView(toSuperview: button, useMargins: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder aDecoder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func requestJSON() {
|
||||||
|
|
||||||
|
requestServer?()
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user