fixing commit

This commit is contained in:
Kevin G Christiano 2019-08-15 09:46:45 -04:00
parent e1c4fdda63
commit 3fedfb3afe

View File

@ -23,7 +23,7 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
//--------------------------------------------------
let folderPath = Bundle.main.resourcePath! + "/JSON"
<<<<<<< HEAD
//--------------------------------------------------
// MARK: - Life Cycle
@ -31,10 +31,10 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
override func viewDidLoad() {
super.viewDidLoad()
=======
var sectionsMap: [AnyHashable: Any] = [:]
override func viewDidLoad() {
func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
@ -51,16 +51,6 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
}
sectionsMap[section] = array
}
}
func getData(for indexPath: IndexPath) -> String? {
let sectionName = self.tableView(tableView, titleForHeaderInSection: indexPath.section)
let array = sectionsMap[sectionName!]! as! Array<Any>
let subPath = (array[indexPath.row] as! String)
let path = "\(folderPath)/\(sectionName!)/\(subPath)"
return try! String.init(contentsOfFile: path)
}
>>>>>>> develop
tableView.delegate = self
tableView.dataSource = self
@ -70,11 +60,19 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
ipTextField.text = "127.0.0.1:8181"
}
func getData(for indexPath: IndexPath) -> String? {
let sectionName = self.tableView(tableView, titleForHeaderInSection: indexPath.section)
let array = sectionsMap[sectionName!]! as! Array<Any>
let subPath = (array[indexPath.row] as! String)
let path = "\(folderPath)/\(sectionName!)/\(subPath)"
return try! String.init(contentsOfFile: path)
}
//--------------------------------------------------
// MARK: - Table View
//--------------------------------------------------
<<<<<<< HEAD
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return try? FileManager.default.contentsOfDirectory(atPath: folderPath)[section]
}
@ -86,25 +84,24 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return try! FileManager.default.contentsOfDirectory(atPath: folderPath + "/" + FileManager.default.contentsOfDirectory(atPath: folderPath)[section]).count
=======
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return (((sectionsMap as NSDictionary).allKeys[section]) as! String)
}
override func numberOfSections(in tableView: UITableView) -> Int {
func numberOfSections(in tableView: UITableView) -> Int {
return sectionsMap.count
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
let sectionName = self.tableView(tableView, titleForHeaderInSection: section)
let array = sectionsMap.arrayForKey(sectionName!)
return array.count
>>>>>>> develop
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
<<<<<<< HEAD
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]
@ -125,14 +122,15 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
button.backgroundColor = .red
button.tag = section // why not... ``\__(~_~)__/``
button.addTarget(self, action: #selector(requestJSON), for: .touchUpInside)
=======
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
let sectionName = self.tableView(tableView, titleForHeaderInSection: indexPath.section)
let array = sectionsMap[sectionName!]! as! Array<Any>
cell.textLabel?.text = (array[indexPath.row] as! String)
>>>>>>> develop
return button
}
@ -142,7 +140,6 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
return true
}
<<<<<<< HEAD
//--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------
@ -173,8 +170,9 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
}
})
})
=======
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
UIPasteboard.general.string = getData(for: indexPath)
let label = UILabel(frame: .zero)
@ -187,12 +185,15 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
view.superview!.addSubview(label)
label.centerXAnchor.constraint(equalTo: view.superview!.centerXAnchor).isActive = true
label.centerYAnchor.constraint(equalTo: view.superview!.centerYAnchor).isActive = true
UIView.animate(withDuration: 2, animations: {
label.alpha = 0
}) { (completed) in
}) { completed in
label.removeFromSuperview()
}
>>>>>>> develop
}
}
}
}
@ -203,15 +204,15 @@ extension MasterViewController: UIDragInteractionDelegate {
let location = session.location(in: tableView)
let indexPath = tableView.indexPathForRow(at: location)
<<<<<<< HEAD
let sectionName = try! FileManager.default.contentsOfDirectory(atPath: folderPath)[indexPath!.section]
let path = try! folderPath + "/" + sectionName + "/" + FileManager.default.contentsOfDirectory(atPath: folderPath + "/" + sectionName)[indexPath!.row]
let content = try! String(contentsOfFile: path)
let provider = NSItemProvider(object: content as NSString)
=======
let content = getData(for: indexPath!)
let provider = NSItemProvider(object: content! as NSString)
>>>>>>> develop
let item = UIDragItem(itemProvider: provider)
return [item]